Skip to content
On this page

Authentication & Access

How to Authenticate

Forms API uses bearer authentication, which involves security tokens that are obtained by an authenticated user via the SnkeOS Developer Portal's authentication/authorization server. To retrieve a bearer token, the user must first exchange a Client ID and Client Secret for an access token from the SnkeOS Developer Portal. The access token is required in all subsequent requests. Your Client ID and Client Secret will be provided to you when your account is initially set up.

Get Access Token

To retrieve the access token simply make a POST request to the Developer Portal authentication server.

Request:

javascript
import axios from "axios";

const getToken = async () => {
  const res = await axios.post(
    "https://login-app.demo.apm.dev.snkeos.com/oauth2/token",
    new URLSearchParams({
      grant_type: "client_credentials",
    }),
    {
      auth: {
        username: "YOUR_CLIENT_ID",
        password: "YOUR_CLIENT_SECRET",
      },
    }
  );
  return res.data;
};

console.log(await getToken());

Response:

javascript
{
  access_token: 'YOUR_ACCESS_TOKEN',
  expires_in: 3600,
  token_type: 'Bearer'
}

Use Bearer Token to Make Requests

Once you have your access token it must be used in all of your requests to the Forms API. Simply send each request with the following Authorization header and Bearer token:

Authorization: Bearer YOUR_ACCESS_TOKEN

Important: The token will grant you access to the API until its expiration. Once the token expires, simply request a new one from the API to continue making requests against it.