SDK
Javascript
How to
Setup Authentication
Apple
Authorize

Authorize with Apple

This method allows you to login to your Xellar Embedded wallet account using an Apple account.

ℹ️

Before getting started, you need to follow Configuring Apple OAuth

Parameters

  • credential (string, required): Credential token (id_token) from Apple login.
  • expireDate (string, optional): The expiration date for the JWT token generated from the response.
  • options (object, optional): Configuration object.
    • rampable (object, optional): Rampable account configuration.
      • username (string): The username for the rampable account.
      • fullName (string): The full name for the rampable account.
      • password (string): The password for the rampable account.

Returns

An AuthSuccessResponse object, potentially including a rampableAccessToken if the rampable option was provided.

If a wallet is created, the response will include a walletToken.

{
  "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "isWalletCreated": true,
  "walletToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
}

If a wallet is not created, the response will include an accessToken.

{
  "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "isWalletCreated": false,
  "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}

If the rampable option was provided, the response will include a rampableAccessToken.

{
  "isWalletCreated": false,
  "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "rampableAccessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}

Example Usage

Basic usage

const credential = "appleCredentialToken";
const response = await sdk.auth.apple.authorize(credential);

With optional parameters

const credential = "appleCredentialToken";
const expireDate = "2023-12-31";
const options = {
  rampable: {
    username: "username",
    fullName: "fullName",
    password: "password"
  }
};
 
const response = await sdk.auth.apple.authorize(credential, expireDate, options);