Authentication
To authenticate the client with the bArchive 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:
import { Bstamp, Network } from 'edeXa-sdk';
async function authenticateClient() {
const bstamp = new Bstamp();
const settings = {
clientId: 'your_client_id',
clientSecret: 'your_client_secret',
network: Network.SANDBOX, // or Network.MAINNET for the mainnet network
};
try {
const authResponse = await bstamp.authenticate(settings);
// Handle Success
} catch (error) {
// Handle Error
}
}
Key Points to Note
- Asynchronous Function: The
authenticateClient
function operates as an asynchronous (async
) function, leveragingawait
to hold execution until thebstamp.authenticate
promise completes. - 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.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
clientId | Yes | Number | Enter your clientId |
clientSecret | Yes | String | The secret of the client |
Response Format
Key | Type | Description |
---|---|---|
id | String | Unique identifier for the user |
token | String | Authentication token |
username | String | Username of the authenticated user |
name | String |