API Reference of GS2-Auth SDK for Game Engine
Model
EzAccessToken
Access token
A model that manages access tokens issued after user authentication. Access tokens are used to identify the identity of a session while a user is logged in to the service. Tokens have an expiration date, and when they expire, re-authentication is required.
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
token | string | ✓ | ~ 1024 chars | Access token | |
userId | string | ✓ | ~ 128 chars | User Id | |
expire | long | ✓ | Difference from current time(1 hours) | Expiration date (Unix time unit:milliseconds) |
Methods
login
Log in to GS2 with the specified user ID
Specify the result of GS2-Account::Authentication for body and signature.
If body and signature are successfully verified, an access token
is responded.
The access token
is temporary authentication information with an expiration time of one hour, and is used to identify the game player for each service in GS2.
The Game Engine SDK for Unity and Unreal Engine 5 provides GS2-Account::Authentication and Profile::Login, which combines this API.
Profile::Login is explained in API Reference / Initialization Process / Game Engine.
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
keyId | string | ✓ | “grn:gs2:{region}:{ownerId}:key:default:key:default” | ~ 1024 chars | encryption key GRN |
body | string | ✓ | ~ 1048576 chars | Account credentials to be signed | |
signature | string | ✓ | ~ 1024 chars | signature |
Result
Type | Description | |
---|---|---|
token | string | access token |
userId | string | User Id |
expire | long | effective date (Unix time unit:milliseconds) |
Implementation Example
var domain = gs2.Auth.AccessToken(
);
var result = await domain.LoginAsync(
body: "body",
signature: "signature",
keyId: "key-0001"
);
var token = result.Token;
var userId = result.UserId;
var expire = result.Expire;
var domain = gs2.Auth.AccessToken(
);
var future = domain.LoginFuture(
body: "body",
signature: "signature",
keyId: "key-0001"
);
yield return future;
if (future.Error != null)
{
onError.Invoke(future.Error, null);
yield break;
}
var token = future.Result.Token;
var userId = future.Result.UserId;
var expire = future.Result.Expire;
const auto Domain = Gs2->Auth->AccessToken(
);
const auto Future = Domain->Login(
"body", // body
"signature", // signature
"key-0001" // keyId
);
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
return false;
}
const auto Result = Future->GetTask().Result();
const auto Token = Result->Token;
const auto UserId = Result->UserId;
const auto Expire = Result->Expire;