Login and Authorization
The Login API provides a temporary code that your game server exchanges for an access token. Never store the client secret in the mini game frontend.
The Authorization API lets you request user authorization for user info.
TT.Login(success, fail)
Initiates the TikTok login flow and returns a temporary code through the success callback. Send this code to your game server to complete the token exchange.
Signature
public static void Login(Action<string> success, Action<string> fail)Parameters
Field | Type | Description | Required |
|
| Success callback receiving a temporary login code | Yes |
|
| Failure callback receiving an error message | No |
Example
if (!CanIUse.Login)
{
Debug.LogError("Login is not available in the current runtime.");
return;
}
TT.Login(
code =>
{
// Send the temporary code to your game server
Debug.Log($"Login code: {code}");
},
errMsg =>
{
Debug.LogError($"Login failed: {errMsg}");
});TT.Authorize(scope, success, fail)
Requests the user's authorization for a scope. On success, send the returned authorization code to your server, which exchanges it for an access token before requesting profile information. For the full flow, see explicit authorization.
Signature
public static void Authorize(string scope, Action<string> success, Action<string, string> fail)Parameters
Field | Type | Description | Required |
|
| The scope to request. Use | Yes |
|
| Called when the user grants authorization. Receives the authorization code. | Yes |
|
| Called when authorization fails or the user denies it. Receives an error code and an error message. | No |
Example
TT.Authorize(
scope: "user.info.basic",
success: code =>
{
// Send the authorization code to your server for token exchange
},
fail: (errCode, errMsg) =>
{
// Handle denial or failure, for example by showing a default avatar
}
);