Authentication
You'll need to authenticate your requests to access any of the endpoints in the n_2 API. In this guide, we'll look at how authentication works. n_2 authenticates requests via bearer tokens.
Receive your access token
Currently the only way to receive your access token is through the /auth/login endpoint. You'll need to provide a registered email adress and password in the request body. Here's an example request using cURL:
Example request to receive access token
curl https://api.n2api.io/v1/auth/login \
-X POST \
-d '{"email":"your-email","password":"password"}'
On success, the API will respond with an access token and a refresh token:
{
"access_token": "aVery.long.token...",
"token_type": "bearer",
"expires_in": 3600,
"refresh_token": "ashortrefreshtoken..."
}
The access token can now be used in the Authorization
header of your requests:
Example request with bearer token
curl -X 'GET' \
'https://api.n2api.io/v1/platforms' \
-H 'accept: application/json' \
-H 'Authorization: Bearer <access_token>'
Future improvements
We are working on a login-free authentication flow. This will allow you to receive your access token without providing your email and password. Instead, you'll be able to use a refresh token to receive a new access token. This will allow you to keep your access token valid for a longer period of time.