Class TokenProviderAbstract

The base class for some "token provider", a general concept for anything that provides some token to the client, whether it be a static token, or if the token is dynamically fetched at runtime, or periodically refreshed.

The TokenProvider.getToken function is called any time the token is required, whether it be for the Data API, or the DevOps API.

astra-db-ts provides all the main token providers you may ever need to use, but you're able to extend this class to create your own if you find it necessary.

Generally, where you can pass in a TokenProvider, you may also pass in a plain string which is translated into a StaticTokenProvider under the hood.

Example

const provider = new UsernamePasswordTokenProvider('username', 'password');
const client = new DataAPIClient(provider);

See

  • StaticTokenProvider
  • UsernamePasswordTokenProvider

Hierarchy (view full)

Constructors

Methods

Constructors

Methods

  • The function which provides the token. It may do any I/O as it wishes to obtain/refresh the token, as it's called every time the token is required for use, whether it be for the Data API, or the DevOps API.

    Returns string | nullish | Promise<(string | nullish)>