TikTok for Developers

Developer Docs

Last updated November 13, 2026

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

Action<string>

Success callback receiving a temporary login code

Yes

fail

Action<string>

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

scope

string

The scope to request. Use user.info.basic.

Yes

success

Action<string>

Called when the user grants authorization. Receives the authorization code.

Yes

fail

Action<string, string>

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
  }
);
TikTok for Developers