# Using escs OAuth for sign in

The goal is to offer the best possible user experience for the players. \
Therefore it would be great if we could skip the escs registration process for players.\
It is possible if you have a backend, where you have your playe&#x72;**'**&#x73; profile data - so if you know your players.

In this case, you can integrate directly with our OAuth service and eliminate the need for the players to go through the registration process in the escs in order to play in tournaments and socialize.

The integration is extremely simple - you have to create an OAuth app (basically press 2 buttons) and make one method call in your backend.

### Integration steps

Go to the main game screen in client.escs.io and press the "Create oAuth App" button - like in the screenshot below

![Press the "Create oAuth App" button](/files/oCEZuab6NNMxLAsUDSRW)

The screen below opens. \
You can leave the App name as it is and enter some text in the description.\
Leave the "Secret key" field blank as well - we will create it for you automatically.\ <mark style="color:red;">**Do not lose this key. Store it somewhere safe! It cannot be recovered if lost.**</mark>\
\
In the Game API Url field, enter the endpoint, where the escs account system will get the player's profile data, using the access token that you will send - read the next part about this.\
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 the "Create App" button. You get the following response:

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

You need to save and copy the keys above: the secret key and the application id. You cannot recover them later.

After that, you can proceed to the "Supporting user login using the game account" section for your plugin. And please read about the "Access token" below.

### **Access token**

escs gets the access token from the game via the corresponding plugin. When a user wants to log into escs using their game account, they press the corresponding button on the escs main screen, and then you will receive a callback in your game, where you can show some permissions request dialog to user and obtain the access token from your game backend. This token along with the list of permissions should be sent to the escs plugin.\
&#x20;\
How the game gets this access token from your backend is completely up to you.&#x20;

After that, the escs backend will receive the aforementioned data and ask your game's API endpoint for actual user profile data. To obtain a player's profile escs account system sends to Game API Url the following POST request:

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

where the **code** is the access token that your game sent to the 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;
}
```

where **email** and **username** are the player's data.

For a better understanding of access token and user's game profile data flow you can use the following diagram:

![Principal diagram of integration flow](/files/CVMDXET2JXalt2Kek7L9)


---

# Agent Instructions: 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-sign-in.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.
