Documentation

PlayerAuthenticationApi

Import

Import

  • const { PlayerAuthenticationApi } = require("@unity-services/player-auth-1.0");

Constructors

Constructor

Methods

Code Confirmation

  • codeConfirmation(projectId: string, bearerAuth: string, unityEnvironment?: string, codeLinkConfirmationRequest?: CodeLinkConfirmationRequest, options?: AxiosRequestConfig<any>): Promise<AxiosResponse<void, any>>
  • Allow a user to sign in to this account using this code

    summary

    Code Confirmation

    throws

    {RequiredError}

    memberof

    PlayerAuthenticationApi

    Parameters

    • projectId: string

      This is the Unity Project Id. It is a uuid format.

    • bearerAuth: string

      This is the bearer token for the user authorized to call this API.

    • Optional unityEnvironment: string
    • Optional codeLinkConfirmationRequest: CodeLinkConfirmationRequest
    • Optional options: AxiosRequestConfig<any>

    Returns Promise<AxiosResponse<void, any>>

Delete Player

  • deletePlayer(playerId: string, projectId: string, options?: AxiosRequestConfig<any>): Promise<AxiosResponse<void, any>>
  • Delete the player.

    summary

    Delete Player

    throws

    {RequiredError}

    memberof

    PlayerAuthenticationApi

    Parameters

    • playerId: string

      This is the player id.

    • projectId: string

      This is the Unity Project Id. It is a uuid format.

    • Optional options: AxiosRequestConfig<any>

    Returns Promise<AxiosResponse<void, any>>

Generate Code

  • Generates a sign in code for an unauthenticated device.

    summary

    Generate Code

    throws

    {RequiredError}

    memberof

    PlayerAuthenticationApi

    Parameters

    • projectId: string

      This is the Unity Project Id. It is a uuid format.

    • Optional unityEnvironment: string
    • Optional generateCodeRequest: GenerateCodeRequest
    • Optional options: AxiosRequestConfig<any>

    Returns Promise<AxiosResponse<GenerateCodeResponse, any>>

Get Code Info

  • Get code information including the identifier and expiration.

    summary

    Get Code Info

    throws

    {RequiredError}

    memberof

    PlayerAuthenticationApi

    Parameters

    • projectId: string

      This is the Unity Project Id. It is a uuid format.

    • codeLinkInfoRequest: CodeLinkInfoRequest

      Code Link Request for Sign In

    • Optional unityEnvironment: string
    • Optional options: AxiosRequestConfig<any>

    Returns Promise<AxiosResponse<CodeLinkInfoResponse, any>>

Get J S O N Web Key Set

  • getJSONWebKeySet(options?: AxiosRequestConfig<any>): Promise<AxiosResponse<JSONWebKeySet, any>>
  • Get the JSON Web Key Set for validating authentication tokens.

    summary

    Get JWKS

    throws

    {RequiredError}

    memberof

    PlayerAuthenticationApi

    Parameters

    • Optional options: AxiosRequestConfig<any>

    Returns Promise<AxiosResponse<JSONWebKeySet, any>>

Get Player

  • getPlayer(playerId: string, projectId: string, options?: AxiosRequestConfig<any>): Promise<AxiosResponse<PlayerResponse, any>>
  • Get the information for a player.

    summary

    Get Player

    throws

    {RequiredError}

    memberof

    PlayerAuthenticationApi

    Parameters

    • playerId: string

      This is the player id.

    • projectId: string

      This is the Unity Project Id. It is a uuid format.

    • Optional options: AxiosRequestConfig<any>

    Returns Promise<AxiosResponse<PlayerResponse, any>>

Link External Id

  • Link an External Id to a Unity Authentication account

    summary

    Link External Id

    throws

    {RequiredError}

    memberof

    PlayerAuthenticationApi

    Parameters

    • idProvider: string

      This is the id provider type.

    • projectId: string

      This is the Unity Project Id. It is a uuid format.

    • linkExternalIdRequest: LinkExternalIdRequest

      Link External Id request body

    • Optional options: AxiosRequestConfig<any>

    Returns Promise<AxiosResponse<LinkExternalIdResponse, any>>

Sign In With Code

  • signInWithCode(projectId: string, codeLinkSessionId: string, signInWithCodeRequest: SignInWithCodeRequest, unityEnvironment?: string, options?: AxiosRequestConfig<any>): Promise<AxiosResponse<AuthenticationResponse, any>>
  • Tries to sign in a user with code. In the case this returns 200 and an empty response, poll at regular intervals, 2-5s to avoid being rate limited, until you receive a different response.

    summary

    Sign In With Code

    throws

    {RequiredError}

    memberof

    PlayerAuthenticationApi

    Parameters

    • projectId: string

      This is the Unity Project Id. It is a uuid format.

    • codeLinkSessionId: string

      An identifier for the device requesting the code sign in.

    • signInWithCodeRequest: SignInWithCodeRequest

      Code Link Request for Sign In

    • Optional unityEnvironment: string
    • Optional options: AxiosRequestConfig<any>

    Returns Promise<AxiosResponse<AuthenticationResponse, any>>

Sign In With External Token

  • Authenticate players using external token. The external tokens are from login providers, such as Facebook.

    summary

    External Token Sign In

    throws

    {RequiredError}

    memberof

    PlayerAuthenticationApi

    Parameters

    • idProvider: string

      This is the id provider type.

    • projectId: string

      This is the Unity Project Id. It is a uuid format.

    • signInWithExternalTokenRequest: SignInWithExternalTokenRequest

      External Token Authentication request body

    • Optional unityEnvironment: string
    • Optional options: AxiosRequestConfig<any>

    Returns Promise<AxiosResponse<AuthenticationResponse, any>>

Sign In With Session Token

  • Authenticate players using the session token. Store the session token in a persistent storage in the app or on device.

    summary

    Session Token Sign In

    throws

    {RequiredError}

    memberof

    PlayerAuthenticationApi

    Parameters

    • projectId: string

      This is the Unity Project Id. It is a uuid format.

    • signInWithSessionTokenRequest: SignInWithSessionTokenRequest

      Session Token Authentication request body

    • Optional unityEnvironment: string
    • Optional options: AxiosRequestConfig<any>

    Returns Promise<AxiosResponse<AuthenticationResponse, any>>

Sign In With Username Password

  • Sign in using the Username Password IdProvider. Store the session token in a persistent storage in the app or on device.

    summary

    Username Password Sign In

    throws

    {RequiredError}

    memberof

    PlayerAuthenticationApi

    Parameters

    • projectId: string

      This is the Unity Project Id. It is a uuid format.

    • usernamePasswordRequest: UsernamePasswordRequest

      The Username and Password of the player.

    • Optional options: AxiosRequestConfig<any>

    Returns Promise<AxiosResponse<AuthenticationResponse, any>>

Sign Up Anonymously

  • Sign-up a new anonymous player.

    summary

    Anonymous Sign Up

    throws

    {RequiredError}

    memberof

    PlayerAuthenticationApi

    Parameters

    • projectId: string

      This is the Unity Project Id. It is a uuid format.

    • signUpAnonymouslyRequest: SignUpAnonymouslyRequest

      Anonymous Sign Up request body

    • Optional unityEnvironment: string
    • Optional options: AxiosRequestConfig<any>

    Returns Promise<AxiosResponse<AuthenticationResponse, any>>

Sign Up With Username Password

  • Create a new player for the Username Password IdProvider. Store the session token in a persistent storage in the app or on device.

    summary

    Username Password Sign Up

    throws

    {RequiredError}

    memberof

    PlayerAuthenticationApi

    Parameters

    • projectId: string

      This is the Unity Project Id. It is a uuid format.

    • usernamePasswordRequest: UsernamePasswordRequest

      The Username and Password of the player.

    • Optional bearerAuth: string
    • Optional options: AxiosRequestConfig<any>

    Returns Promise<AxiosResponse<AuthenticationResponse, any>>

Unlink External Id

  • Unlink an external account from a Unity Authentication account.

    summary

    Unlink External Id

    throws

    {RequiredError}

    memberof

    PlayerAuthenticationApi

    Parameters

    • idProvider: string

      This is the id provider type.

    • projectId: string

      This is the Unity Project Id. It is a uuid format.

    • unlinkExternalIdRequest: UnlinkExternalIdRequest

      Unlink external Id request body

    • Optional options: AxiosRequestConfig<any>

    Returns Promise<AxiosResponse<UnlinkExternalIdResponse, any>>

Username Password Update Password

  • Update the password of a player using the Username Password IdProvider. Store the session token in a persistent storage in the app or on device.

    summary

    Username Password Update Password

    throws

    {RequiredError}

    memberof

    PlayerAuthenticationApi

    Parameters

    • projectId: string

      This is the Unity Project Id. It is a uuid format.

    • bearerAuth: string

      This is the bearer token for the user authorized to call this API.

    • usernamePasswordPasswordUpdateRequest: UsernamePasswordPasswordUpdateRequest

      The Username, current Password and new Password of the player.

    • Optional options: AxiosRequestConfig<any>

    Returns Promise<AxiosResponse<AuthenticationResponse, any>>