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 specific scopes such as user profile, contact list, or other protected resources.
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(param)
Requests user authorization for the specified scope. The authorization result is delivered through callbacks.
Signature
public static void Authorize(AuthorizeParam param)Parameters
Field | Type | Description | Required |
|
| Authorization scope (e.g., | Yes |
|
| Success callback | No |
|
| Failure callback | No |
|
| Completion callback | No |
Example
TT.Authorize(new AuthorizeParam
{
scope = "user.info",
Success = result => Debug.Log("Authorization granted"),
Fail = error => Debug.LogError(error.ErrMsg),
Complete = () => Debug.Log("Authorization flow completed")
});