Authentication and authorization
Quickstart
Last updated
Was this helpful?
Quickstart
Last updated
Was this helpful?
The OAuth 2.0 password grant flow allows applications to obtain an access token by directly collecting the user's credentials. This guide explains how to implement this flow to retrieve a bearer token using client credentials and user authentication.
Before you begin, ensure you have the following credentials:
1.
Client ID
Your application's unique identifier (received from the Semansys support desk).
2.
Client secret
A secret known only to your application and the authorization server (received from the Semansys support desk).
3.
Username
The resource owner's username (the e-mail address used retrieving the API credentials).
4.
Password
The resource owner's password (received from the Semansys support desk).
Create a POST request to the token endpoint with the following parameters:
grant_type
password
Specifies the OAuth flow type.
client_id
your_client_id
Your application's unique identifier.
client_secret
your_client_secret
Your application's secret.
username
user_username
The resource owner's username.
password
user_password
The resource owner's password.
Using cURL
Using JavaScript/Node.js
Using Python
Upon successful authentication, the server will respond with a JSON object containing:
Key response fields:
access_token
The bearer token to use for authentication.
token_type
The type of token (always "bearer" in this case).
expires_in
Token validity period in seconds.
refresh_token
Token used to obtain a new access token when the current one expires.
scope
Permissions granted to the access token.
To use the bearer token for API requests, include it in the Authorization header:
Example request with the bearer token:
Common error responses:
400
Bad Request
Invalid request parameters.
401
Unauthorized
Invalid client credentials.
403
Forbidden
User authentication failed.
If you receive an error, check:
All required parameters are included and correctly formatted
Client id and client secret are valid
User credentials are correct.