Skip to main content

Custom authentication

Instead of using the authentication server provided by BACKND, you can link a self-developed user authentication server with the chat server. This is recommended for teams that have already implemented an authentication server and user DB. If you use this function, you will not be charged for the user management call and DB costs.

Structure

A process for receiving user information needed for chat from the custom authentication server.

  1. The user requests login and completes authentication, then receives a token from the custom authentication server.
  2. With the received token, a request for access is sent to the chat server.
  3. The chat server sends the token to the custom authentication server.
  4. The custom authentication server sends user information to the chat server, and the user connects to the chat server.
TIP: What if the game does not require a login authentication process?

A custom authentication function can be used with an echo server, where user information is received instead of a token and returned as-is.

How to use

In BACKND Console, configure the endpoint of the custom authentication server you wish to connect.
Then, connect to the chat server using a user token from the client side.

Custom authentication API settings

In Console > Chat > Settings menu, you can set the custom server's authentication API endpoint.

The chat server sends an HTTP request in the following way:

HTTP request

POST https://auth.mygame.com

Headers

Content-Type: application/json; charset=utf8
token: USER_TOKEN

Request body

Property nameTypeValueDescription
sourcestringthebackend-chat-apiRequested server name (BACKND's chat server)
{
"source": "thebackend-chat-api",
}

Responses

Configure it to return a response with the correct format.
The user information must contain a nickname and uid in a string format.
The uid must be a unique value assigned to each user because users are distinguished using the uid.

The following is an example of the user information sent from the custom server to the chat server:

Status: 200 OK
{
"nickname": "john doe",
"uid": "1234"
}

Also, language can be sent as an option. language can be used to effectively utilize the translation and language channel functions.
The language value must follow the ISO 639-1 language code format and may contain a country code. (language code list)

Status: 200 OK
{
"nickname": "john doe",
"uid": "1234",
"language": "en-US"
}

Connect to a chat server

On the client side, use the following code to connect to the chat server with an authenticated user token:

BackndChat::BDChatClientArguments args;
args.UUID = "xxxx-xxxx-xxxxxx-xxxxxxx";
args.CustomAccessToken = "USER_TOKEN"
args.Avatar = "default";
args.Metadata = "{}";

BackndChat::BDChatMain::Initialize(this, args);