# Server Integration Basics

### Introduction

The Unity Server Integration package comprises three main components: `LoginManager`, `LoginEditorWindow`, and `AuthTokenManager`. Together, these scripts provide a solution for authenticating Unity users, fetching data from a server, and managing authentication tokens within the Unity Editor.

- **LoginManager**: Responsible for interfacing directly with the server. It sends login credentials, retrieves user data, models, and projects.
  
- **LoginEditorWindow**: Provides a user-friendly GUI within the Unity Editor for users to input their credentials, initiate server requests, and view fetched data.
  
- **AuthTokenManager**: A utility class that centrally manages the authentication token, ensuring secure storage and easy access for server requests.

### Key Functionalities

1. **User Authentication**:
   - Users can input their `username` and `password` within the `LoginEditorWindow`.
   - Upon confirming, `LoginManager` sends the credentials to the server.
   - Successful authentication returns a token, stored using `AuthTokenManager`.

2. **Fetching Data**:
   - Once authenticated, users can fetch models, projects, and their user data via buttons in the `LoginEditorWindow`.
   - The data retrieval is handled by `LoginManager`, which sends requests to the server using the token from `AuthTokenManager`.
   - Fetched data is displayed within the `LoginEditorWindow`.

3. **Token Management**:
   - `AuthTokenManager` provides a centralized way to store and retrieve the authentication token.
   - The token is essential for making authenticated requests to the server after the initial login.

### Workflow

1. Open the `LoginEditorWindow` via `Tools > Login Manager` in the Unity Editor.
2. Input your `username` and `password`, then click "Confirm".
3. Upon successful login, the authentication token is stored.
4. Use the "Fetch Models/Projects" and "Fetch User Data" buttons to retrieve data from the server.
5. View the fetched data directly within the `LoginEditorWindow`.