Skip to main content

Authentication

To authenticate the client with the edeXa API, utilize the authenticate method from the SDK. This process is essential for establishing a secure connection with the edeXa services.


Sample Code Snippet

Here is a JavaScript code snippet demonstrating the use of the authenticate method:

// SDK.js
import { ERC20, Network } from 'edeXa-sdk';

async function authenticateClient() {
const erc20 = new ERC20();
const settings = {
client_id: 'your_client_id',
secret_key: 'your_client_secret',
network: Network.SANDBOX, // or Network.MAINNET for the mainnet network
};

try {
const authResponse = await erc20.authenticate(settings);
// Handle success
} catch (error) {
// Handle error
}
}

Key Points to Note

  • Asynchronous Function: The authenticateClient function is an asynchronous (async) function, which uses await to wait for the erc20.authenticate method's promise to resolve.
  • Client Credentials: Substitute your_client_id and your_client_secret with the genuine client ID and client secret assigned to you. These credentials are available in the edeXa Developer Settings.

Response Format

Upon successful authentication, the response will include several key pieces of information:

KeyTypeDescription
idStringUnique identifier for the user
tokenStringAuthentication token
usernameStringUsername of the authenticated user
emailStringEmail address of the user