Documentation

LoginWithTwitch

Signs the user in using a Twitch access token.

Request Details

More details regarding Twitch and their authentication system can be found at https://github.com/justintv/Twitch-API/blob/master/authentication.md. Developers must provide the Twitch access token that is generated using one of the Twitch authentication flows. PlayFab will use the title's unique Twitch Client ID to authenticate the token and log in to the PlayFab system. If CreateAccount is set to true and there is not already a user matched to the Twitch username that generated the token, then PlayFab will create a new account for this user and link the ID. In this case, no email or username will be associated with the PlayFab account. If there is already a different PlayFab user linked with this account, then an error will be returned.

LoginWithTwitchRequest
Request Properties
AccessToken String

Token issued by Twitch's API for the user.

CreateAccount Boolean

Automatically create a PlayFab account if one is not currently linked to this ID.

EncryptedRequest String

Base64 encoded body that is encrypted with the Title's public RSA key (Enterprise Only).

InfoRequestParameters GetPlayerCombinedInfoRequestParams

Flags for which pieces of info to return for the user.

PlayerSecret String

Player secret that is used to verify API request signatures (Enterprise Only).

TitleId (required) String

Unique identifier for the title, found in the Settings > Game Properties section of the PlayFab developer site when a title has been selected.

POST https://{{TitleID}}.playfabapi.com/Client/LoginWithTwitch
    Content-Type: application/json
{
  "AccessToken": "SomeTwitchTokenHere",
  "CreateAccount": false,
  "TitleId": "123"
}
        

Response Details

LoginResult
Result Properties
EntityToken EntityTokenResponse

If LoginTitlePlayerAccountEntity flag is set on the login request the title_player_account will also be logged in and returned.

InfoResultPayload GetPlayerCombinedInfoResultPayload

Results for requested info.

LastLoginTime DateTime

The time of this user's previous login. If there was no previous login, then it's DateTime.MinValue

NewlyCreated (required) Boolean

True if the account was newly created on this login.

PlayFabId String

Player's unique PlayFabId.

SessionTicket String

Unique token authorizing the user and game at the server level, for the current session.

SettingsForUser UserSettings

Settings specific to this user.

Sample Response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
{
  "code": 200,
  "status": "OK",
  "data": {
    "SessionTicket": "50DF92E291CCD4C3---A54F-8D3909FF54DEE10-B7817722BC94E536.A6DCCFE1C9709ABB",
    "PlayFabId": "50DF92E291CCD4C3",
    "NewlyCreated": false
  }
}

Authentication

None

Possible Error Codes

Name Code
AccountNotFound 1001
DownstreamServiceUnavailable 1127
FeatureNotConfiguredForTitle 1177
InvalidTitleId 1004
InvalidTwitchToken 1232
RequestViewConstraintParamsNotAllowed 1303
TwitchResponseError 1233