Skip to main content
All CollectionsAPI Documentation
Obtain Bearer Token using curl or code
Obtain Bearer Token using curl or code

How to get a token to make API requests with

Ted Tigerschiöld avatar
Written by Ted Tigerschiöld
Updated over 3 years ago

This article assumes that you have already aquired your client credentials as described in Calling the API.

Allows a registered application to obtain an OAuth 2 Bearer Token, which can be used to make API requests on an application's own behalf, without a user context. This is called Application-only authentication.

A Bearer Token may be invalidated using oauth2/invalidate_token.

Successful responses include a JSON-structure describing the awarded Bearer Token.

Resource URL

https://auth.app.labelf.ai/oauth2/token

Resource information

Response formats

JSON

Requires authentication?

Yes - Basic auth with your client_id as your username and client_secret as your password

Parameters

Name

Required

Description

Default Value

Example

grant_type

required

Specifies the type of grant being requested by the application. At this time, only client_credentials is allowed

client_credentials

Example Request

POST /oauth2/token HTTP/1.1
Host: auth.app.labelf.ai
Authorization: Basic eHZ6MWV2R ... o4OERSZHlPZw==
Content-Type: application/x-www-form-urlencoded;charset=UTF-8

grant_type=client_credentials

Example Curl Request

curl -k -X POST -H \
"Content-Type: application/x-www-form-urlencoded" \
-u 'CLIENT_ID:CLIENT_SECRET' \
-d grant_type=client_credentials \ https://auth.app.labelf.ai/oauth2/token

Example Response

HTTP/1.1 200 OK 
Status: 200 OK
Content-Type: application/json; charset=utf-8
...
{
"access_token": "asdAASDASDASD_SASDASD",
"expires_in": 3122063999,
"scope": "",
"token_type": "bearer"
}
Did this answer your question?