SDK
Javascript
How to
Setup Authentication
Google
Authorize

OAuth Google Authorize

Before getting started, you need to follow Configuring Google OAuth

This method allows you to login to your Xellar Embedded wallet account using a Google account.

Parameters

  • credentials (string, required): Credential token from Google login.
  • expiredDate (Date, 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 credentials = "googleCredentialToken";
const expiredDate = "2023-12-31";
const response = await sdk.auth.google.authorize(credentials, expiredDate);

With rampable option

const credentials = "googleCredentialToken";
const expiredDate = "2023-12-31";
const options = {
  rampable: {
    username: "username",
    fullName: "fullName",
    password: "password"
  }
};
 
const response = await sdk.auth.google.authorize(credentials, expiredDate, options);