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 usesawait
to wait for theerc20.authenticate
method's promise to resolve. - Client Credentials: Substitute
your_client_id
andyour_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:
Key | Type | Description |
---|---|---|
id | String | Unique identifier for the user |
token | String | Authentication token |
username | String | Username of the authenticated user |
String | Email address of the user |