Skip to main content
Version: 5.7.0

AuthenticateApple

Authenticates the user using Sign in with Apple.

To use this authentication method, your app must first perform the client-side portion of the Sign in with Apple login, and then pass the JWT returned from Apple to the AuthenticateApple() API call.

For more information, see Apple's Sign in with Apple Documentation.

caution

Make sure you've initialized the brainCloud library before authenticating.

ServiceOperation
authenticationV2AUTHENTICATE

Method Parameters

ParameterDescription
appleUserIdThe user id of the authenticated user. It should match the sub field of the identity token. This is the identifier that will be attached to the user's profile.
identityTokenThe JSON Web Token that represents the user's identity. Retrieved as part of the users profile, given back after successfully signing in with apple.
forceCreateShould a new profile be created for this user if the account does not exist?

Usage

http://localhost:3000
string appleUserId = "00123.xxxxxxxx";
string identityToken = "identityTokenFromApple";
bool forceCreate = true;

_bc.AuthenticationService.AuthenticateApple(
appleUserId, identityToken, forceCreate, SuccessCallback, FailureCallback);
JSON Response
{
"status": 200,
"data": {
"vcPurchased": 0,
"experiencePoints": 100,
"refundCount": 0,
"playerSessionExpiry": 60,
"server_time": 1464621990155,
"experienceLevel": 0,
"currency": {
"credits": {
"purchased": 0,
"balance": 12211,
"consumed": 133,
"awarded": 12344
}
},
"abTestingId": 8,
"statistics": {
"gamesWon": 0
},
"id": "323e861-b749-4ce4-a57a-175232e21b5d",
"createdAt": 1459439058035,
"profileId": "323e861-b749-4ce4-a57a-175232e21b5d",
"newUser": "false",
"xpCapped": false,
"sent_events": [],
"timeZoneOffset": -5,
"playerName": "",
"vcClaimed": 0,
"parentProfileId": null,
"rewards": {
"rewardDetails": {},
"rewards": {},
"currency": {}
},
"countryCode": "ca",
"loginCount": 16,
"emailAddress": "test@email.com",
"previousLogin": 1464621979514,
"incoming_events": [],
"lastLogin": 1464621990118,
"languageCode": "en",
"pictureUrl": null,
"sessionId": "v3grtg3ve0a089pekk8lneuk8k",
"amountSpent": 0
}
}
Common Error Code

Status Codes

CodeNameDescription
40206MISSING_IDENTITY_ERRORThe identity does not exist on the server and forceCreate was false [and a profileId was provided - otherwise 40208 would have been returned]. Will also occur when forceCreate is true and a saved [but un-associated] profileId is provided. The error handler should reset the stored profile id (if there is one) and re-authenticate, setting forceCreate to true to create a new account. A common cause of this error is deleting the user's account via the Design Portal.
40207SWITCHING_PROFILESIndicates that the identity credentials are valid, and the saved profileId is valid, but the identity is not associated with the provided profileId. This may indicate that the user wants to switch accounts in the app. Often an app will pop-up a dialog confirming that the user wants to switch accounts, and then reset the stored profileId and call authenticate again.
40208MISSING_PROFILE_ERRORReturned when the identity cannot be located, no profileId is provided, and forceCreate is false. The normal response is to call Authenticate again with forceCreate set to true.
40217UNKNOWN_AUTH_ERRORAn unknown error has occurred during authentication.
40307TOKEN_DOES_NOT_MATCH_USERThe user credentials are invalid (i.e. appleUserId and identityToken are invalid). May also indicate that Apple Integration is not properly configured.