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 { Barchive, Network } from 'edeXa-sdk';
async function authenticateClient() {
const barchive = new Barchive();
const settings = {
clientId: 'your_client_id',
clientSecret: 'your_client_secret',
network: Network.SANDBOX, // or Network.MAINNET for the mainnet network
};
try {
const authResponse = await barchive.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 thebarchive.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.
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 |