Skip to content

Latest commit

 

History

History
280 lines (191 loc) · 5.43 KB

TokensApi.md

File metadata and controls

280 lines (191 loc) · 5.43 KB

Fastly.TokensApi

const apiInstance = new Fastly.TokensApi();

Methods

Note

All URIs are relative to https://api.fastly.com

Method HTTP request Description
bulkRevokeTokens DELETE /tokens Revoke multiple tokens
createToken POST /tokens Create a token
getToken GET /tokens/{token_id} Get a token
getTokenCurrent GET /tokens/self Get the current token
listTokensCustomer GET /customer/{customer_id}/tokens List tokens for a customer
listTokensUser GET /tokens List tokens for the authenticated user
revokeToken DELETE /tokens/{token_id} Revoke a token
revokeTokenCurrent DELETE /tokens/self Revoke the current token

bulkRevokeTokens

bulkRevokeTokens({ , [request_body] })

Revoke Tokens in bulk format. Users may only revoke their own tokens. Superusers may revoke tokens of others.

Example

const options = {
  request_body: {"data":[{"id":"3krg2uUGZzb2W9Euo4moOY","type":"token"},{"id":"71ZA6hv2FO6tGEQIE203Xj","type":"token"}]},
};

apiInstance.bulkRevokeTokens(options)
  .then(() => {
    console.log('API called successfully.');
  })
  .catch((error) => {
    console.error(error);
  });

Options

Name Type Description Notes
request_body {String: Object} [optional]

Return type

null (empty response body)

createToken

createToken()

Create an API token. If two-factor authentication is enabled for your account, review the instructions for including a one-time password in the request.

Example

apiInstance.createToken()
  .then((data) => {
    console.log(data, "API called successfully.");
  })
  .catch((error) => {
    console.error(error);
  });

Options

This endpoint does not need any parameters.

Return type

TokenCreatedResponse

getToken

getToken({ token_id })

Get a single token by its id.

Example

const options = {
  token_id: "token_id_example", // required
};

apiInstance.getToken(options)
  .then((data) => {
    console.log(data, "API called successfully.");
  })
  .catch((error) => {
    console.error(error);
  });

Options

Name Type Description Notes
token_id String Alphanumeric string identifying a token.

Return type

TokenResponse

getTokenCurrent

getTokenCurrent()

Get a single token based on the access_token used in the request.

Example

apiInstance.getTokenCurrent()
  .then((data) => {
    console.log(data, "API called successfully.");
  })
  .catch((error) => {
    console.error(error);
  });

Options

This endpoint does not need any parameters.

Return type

TokenResponse

listTokensCustomer

listTokensCustomer({ customer_id })

List all tokens belonging to a specific customer.

Example

const options = {
  customer_id: "customer_id_example", // required
};

apiInstance.listTokensCustomer(options)
  .then((data) => {
    console.log(data, "API called successfully.");
  })
  .catch((error) => {
    console.error(error);
  });

Options

Name Type Description Notes
customer_id String Alphanumeric string identifying the customer.

Return type

[TokenResponse]

listTokensUser

listTokensUser()

List all tokens belonging to the authenticated user.

Example

apiInstance.listTokensUser()
  .then((data) => {
    console.log(data, "API called successfully.");
  })
  .catch((error) => {
    console.error(error);
  });

Options

This endpoint does not need any parameters.

Return type

[TokenResponse]

revokeToken

revokeToken({ token_id })

Revoke a specific token by its id.

Example

const options = {
  token_id: "token_id_example", // required
};

apiInstance.revokeToken(options)
  .then(() => {
    console.log('API called successfully.');
  })
  .catch((error) => {
    console.error(error);
  });

Options

Name Type Description Notes
token_id String Alphanumeric string identifying a token.

Return type

null (empty response body)

revokeTokenCurrent

revokeTokenCurrent()

Revoke a token that is used to authenticate the request.

Example

apiInstance.revokeTokenCurrent()
  .then(() => {
    console.log('API called successfully.');
  })
  .catch((error) => {
    console.error(error);
  });

Options

This endpoint does not need any parameters.

Return type

null (empty response body)

[Back to top] [Back to API list] [Back to README]