Skip to content

Get or refresh authorization token endpoint

POST https://atomgit.com/oauth/token

This unified endpoint is called to obtain or refresh an access token (access_token).

Request parameters

Parameter Location Type Required Description
grant_type query string Yes Grant type. Allowed values: authorization_code: authorization code grant, used to obtain a new token; refresh_token: refresh token grant, used to refresh an existing token
code query string Conditional Authorization code. Required when grant_type=authorization_code
client_id query string Conditional The registered client ID. Required when grant_type=authorization_code
refresh_token query string Conditional Refresh token. Required when grant_type=refresh_token

Response parameters

Field Type Always returned Nullable Description
access_token string Yes No Access token (access_token)
expires_in string Yes No Expiration time
refresh_token string Yes No Refresh token (refresh_token)
scope string Yes No Permission scope (scope)
created_at string Yes No Creation date

Error responses

The endpoint may return the following error responses:

400 Parameter error

{
  "errorCode": "BAD_REQUEST",
  "errorCodeName": "Bad Request",
  "errorMessage": "page must be greater than 0"
}

401 Unauthenticated

{
  "errorCode": 401,
  "errorCodeName": "UNAUTHORIZED",
  "errorMessage": "Unauthorized"
}

HTTP response status codes

Status code Description
200 Success (OK)
400 Parameter error (Bad Request)
401 Unauthenticated (Unauthorized)
403 Access forbidden (Forbidden)
404 Not found (Not Found)
429 Too many requests (Too Many Requests)
500 Internal system error (Internal Server Error)

Request example

cURL

curl -L -X POST 'https://atomgit.com/oauth/token' \
-H 'Content-Type: multipart/form-data' \
-H 'Accept: application/json'

JavaScript

const myHeaders = new Headers();
myHeaders.append("Content-Type", "multipart/form-data");
myHeaders.append("Accept", "application/json");

const requestOptions = {
  method: "POST",
  headers: myHeaders,
  redirect: "follow"
};

fetch("https://atomgit.com/oauth/token", requestOptions)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.error(error));

Response example

Status code: 200

{
  "access_token": "string",
  "expires_in": 0,
  "refresh_token": "string",
  "scope": "string",
  "created_at": "string"
}

Error codes

Error code Description
200 Success (OK)
400 Parameter error or the request cannot be parsed (for example, invalid page / per_page values)
401 Unauthenticated or invalid credentials
403 Forbidden
404 The request path does not exist
405 The request method is not supported
429 Too many requests; the rate limit was triggered
500 Internal system error

Markdown source: View on AtomGit·Content from the open-source project gitcode-dev/atomgit-api-doc