Skip to content

Authentication

Authentication Using OAuth2

We are able to authenticate with the Everysk API using the OAuth2 Client Credentials grant type. Click here to learn more about this type of authentication

First we need to obtain the acess token,

So using the following headers and body make a POST request to the following endpoint

curl https://api.everysk.com/v2/oauth2/token \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "grant_type=client_credentials&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET" \
  -X POST

The response should look something like this:

{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "token_type": "Bearer",
  "expires_in": 3600,
  "scope": "delete get post put"
}

The scope field of the response contains the scopes of the access token, separated by spaces. The scopes are lowercase and in alphabetical order. Each scope, except sdk, gives access to one HTTP method:

Scope Permission
get Read access: retrieve entities and their data.
post Create access: create new entities and run calculations.
put Modify access: update existing entities.
delete Delete access: remove entities.
sdk Access to the Python SDK. It gives access to all SDK methods: read, write and delete. The role of the user still limits the calls.

A token gets all the scopes of its credential. To get fewer scopes, send the scope parameter in the token request, for example scope=get. The response then repeats the scope value that you sent. A scope that the credential does not have returns 400 with {"error": "invalid_scope"}.

A request with a token that does not have the scope of the HTTP method returns 403.

The token endpoint returns errors in the OAuth2 format, not in the format of the other errors:

Code Body When
400 {"error": "unsupported_grant_type"} grant_type is not client_credentials.
400 {"error": "invalid_scope"} scope asks for a scope the credential does not have.
401 {"error": "invalid_client"} The client_id or the client_secret is not valid.

Now include the token in your API calls like this:

curl https://api.everysk.com/v2/... \
  -H "Authorization: Bearer <ACCESS_TOKEN>"

where <ACCESS_TOKEN> should be replaced with the value returned in the previous response.

You can manage your OAuth2 credentials (client ID, client secret, and tokens) in the OAuth2 Credentials page.

A few things to keep in mind

  • Never expose the client_secret in frontend code

  • Perform token requests on the backend

  • Store credentials securely

  • Refresh token when expired — tokens expire after 1 hour. To get a new one, simply call the same token endpoint again with your client_id and client_secret


Authentication Using API Key


Deprecated

This authentication method is not recommended for new projects. Please use Authentication Using OAuth2 instead.

Authenticate your account when using the API by including your secret API key in the request. Authentication to the API is performed via HTTP Basic Authentication. API requests without authentication will fail. Create and manage your credentials in the API Keys tab of the API Manager.


A request example with arguments:

curl https://api.everysk.com/v2/health_check \
  -H "Authorization: Bearer YOUR_ACCOUNT_SID:YOUR_AUTH_TOKEN" \
  -G


The above call returns a JSON structure like this:

{
  "api_status": "OK",
  "version": "v2",
  "name": "Everysk API"
}