Creating a NowSecure Platform API Bearer Token

Create a Bearer Token
Token Expiration
REST API Calls

Create a Bearer Token

Follow the steps below to create a API token that can be used for standard API calls as well as Platform Findings GraphQL API.

Begin by logging in and selecting your Profile icon in the upper right corner.

Screen_Shot_2022-07-07_at_10.14.58_AM.png

Next, select Tokens.

step2.png

Select the Generate Token button in the upper right side of the screen, then type your Token name in the field. Select Generate Token. The name is for your reference only and will not impact the process of using the token.

token1.png

A box with the token will appear below.
Note: The token has been redacted from the box for purposes of the tutorial.

liquid.png

Copy the string or use the Copy Token button below the box to do so. Make sure to save your Token somewhere safe as it is linked to your account.

Token Expiration

Token management can be found in your user profile within My Account > Tokens.

Group admins can also access token management from the Admin tab in the top menu > Tokens.

token2.png

Platform Admins will have the ability to set token expiration for newly created API tokens. Any newly created token will have the default expiration of 365 days, unless adjusted by the admin. 

Note: All existing tokens will continue to have NO expiration date or a default expiration. The best practice recommendation is to update all existing tokens with a set expiration based on your workflows.

  • No user can override an organization level expiration or revocation set by an Admin 
  • Users can set the expiration date for up to 365 days and/or revoke their tokens
  • All changes to tokens are captured in the Audit Log tab on the left rail within the Admin tab
  • Admins and users can view the following information on the Tokens page:
    • Token name
    • Created date/time
    • Expired/Expiration date
    • Revoked action
  • Token expiration is set in UTC+0
  • The default setting for tokens is 365 days if no expiration date is set
  • A “Default Maximum Lifetime Days” feature allows a default setting for all future token creation

REST API Calls

Create a Bearer Token

Use this command to create a Platform API bearer token. 

curl --location 'https://lab-api.nowsecure.com/user/token/' \
--header 'Authorization: Bearer <REDACTED>' \
--header 'Content-Type: application/json' \
--data '{"name": "new_token_via_api"}'

List a User's Tokens

Use this command to list all tokens created by a user. 

curl --location 'https://lab-api.nowsecure.com/user/token/' \
--header 'Authorization: Bearer ${API_TOKEN}' \

Token List Output Example: 

[{"jti":"JTI_ID","iss":"lab-api.nowsecure.com","sub":"USER_ID","name":"TOKEN_NAME","iat":TOKEN_CREATION_DATE,"exp":TOKEN_EXPIRATION_DATE}

Token Expiration

Use the following GET command to add a token expiration to a specific NowSecure Platform token.

GET https://lab-api.nowsecure.com/user/token/
curl --location 'https://lab-api.nowsecure.com/user/token/' \
--header 'Authorization: Bearer ${API_TOKEN}' \
--header 'Content-Type: application/json' \
--data '{
    "name": "token_expires_soon",
    "expirationDays": 1
}'

Comments

0 comments

Article is closed for comments.