> For the complete documentation index, see [llms.txt](https://docs.escs.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.escs.io/using-escs-oauth-for-automated-user-sign-in-in-your-gamehub.md).

# Using escs OAuth for automated user sign in in your GameHub

The goal is to offer the best possible user experience.\
You can skip the escs registration flow and sign users in to GameHub with their existing account credentials.\
\
The integration is simple. You create an OAuth app and make one method call in your app.

### Integration steps

Go to [client.demo.escs.io](https://client.demo.escs.io/) and create a temporary game as described in [Integration - step 1](/integration-step-1.md).\
**You only need to create the app. No further setup is required.**

Then open the game settings and press **Create oAuth App**, as shown below.

<figure><img src="/files/2fwEGo0ZlDPF3MtSDOxD" alt=""><figcaption></figcaption></figure>

The following screen opens.\
You can keep the default app name and enter any description.\
Leave the **Secret key** field blank. It is created automatically.\ <mark style="color:red;">**Do not lose this key. Store it somewhere safe! It cannot be recovered if lost.**</mark>\
\
In **Game API URL**, enter the endpoint where the escs account system can fetch the player's profile data by using the access token you send.\
This endpoint must validate the access token and respond with the profile data.

![Fill in the fields and press the "Create App" button.](/files/gFYzHhEbZTqtr7ToDtlK)

Press **Create App**. You will get the following response:

![Copy and save the keys! You cannot recover them later.](/files/HQYzuK4nAT8qLjdeYsgl)

Save both keys shown above: the secret key and the application ID.\
You cannot recover them later.

Then continue with the **Access token** section below.

### **Access token**

escs receives the access token from your app through the corresponding post message, as described in the GameHub integration guide.\
\
How your app gets this access token from your backend is up to you.

After that, the escs backend uses that data to request the actual user profile from your API endpoint.\
To get a user's profile, the escs account system sends the following POST request to **Game API URL**:

```
export interface Request {
  code: string;
  secretKey: string;
  applicationId: string;
}
```

Here, `code` is the access token your app sent to escs, and `secretKey` is the generated key from the client dashboard.\
\
escs expects a response in the following format:

```
export interface Response {
  _id: string;
  email?: string;
  username?: string;
}
```

Here, `email` and `username` contain the player's data.\
\
After that, the player is signed in.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.escs.io/using-escs-oauth-for-automated-user-sign-in-in-your-gamehub.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
