Svrf Library Initialization and Authentication
Svrf
Create a new Svrf instance. When creating a new instance, the library will automatically authenticate your Svrf API Key.
Options
Options can be provided to adjust the API client's settings.
Manual Authentication
If you want to postpone the initial authentication request and manually control when the Svrf API Key is authenticated, you can set isManualAuthentication
option to true
. Then call svrf.authenticate()
manually to authenticate the Svrf API Key.
Authentication Tokens
The library will automatically handle attaching your Authentication Token to your requests' headers and renew expired tokens.
Custom Token Storage
Authentication tokens will be automatically saved in localStorage
. If localStorage
is not available—such as in Node.js—the library will save the Authentication Token in memory. Optionally, you can provide your own custom token storage methods using the storage
option.
Syntax
const svrf = new Svrf(apiKey [, options]);// Orconst svrf = new Svrf(apiKey, {isManualAuthentication: false,storage: {get: () => {return yourCustomStorage.read();},set: (value) => {return yourCustomStorage.write(value);},clear: () => {return yourCustomStorage.clear();},},})
Parameters
Parameter | Type | Description |
---|---|---|
apiKey | string | Your Svrf API Key. |
options | object? | Advanced API client options. |
options.isManualAuthentication | boolean? | Trigger the authentication of your Svrf API Key manually. Defaults: false |
options.storage | object? | Use custom methods to get, set, and clear the authentication token. If none is provided, the application will use localStorage to store the authentication token. If localStorage is not available, the token will be stored in memory. |
Return Value
Returns a promise.
authenticate()
Authenticates apiKey
with the Svrf API using the Authenticate Endpoint.
When you create a new Svrf instance, the library will automatically authenticate your Svrf API Key.
However, you may want to postpone the initial authentication request and manually control when the Svrf API Key is authenticated. In that case, you can set isManualAuthentication
option to true
. Then call svrf.authenticate()
manually whenever you want.
The library will automatically handle attaching your Authentication Token to your requests' headers and renew expired tokens.
Authentication tokens will be automatically saved in localStorage
. If localStorage
is not available—such as in Node.js—the library will save the Authentication Token in memory. Optionally, you can provide your own custom token storage methods.
Syntax
const Svrf = require('svrf');const svrf = new Svrf('YOUR API KEY HERE', {isManualAuthentication: true,};svrf.authenticate();
Parameters
Parameters | Type | Description |
---|---|---|
apiKey | string | Your Svrf API Key. |
Return Value
Returns a promise.