Skip to content

generateToken_client_credential

jrichardsz edited this page Aug 23, 2023 · 2 revisions

Client Credentials Grant

The Client Credentials grant type is used by clients to obtain an access token outside of the context of a user.

This is typically used by clients to access resources about themselves rather than to access a user's resources.

Base Url : {{eventhos-api-base-url}}

Endpoint : /auth/token

Method : POST

Auth required : No

Permissions required : none

Request

type: body

client_id=*********&client_secret=*******&grant_type=client_credentials

Request Headers Description

key value description
content-type application/x-www-form-urlencoded Sends encoded data to the server using the request body in the form of key=value pairs. For non standard clients you coul use json

Request Fields Description

key value description
grant_type client_credentials Send client_credentials according to your needs
client_id ****** The client id
client_secret ****** The client secret

This request is similar to the oauth2 spec:

Response

{
  "code": 200000,
  "message": "Token generated for client *****",
  "content": {
    "jwt_token": "******",
    "name": "Subject name",
    "description": "Subject description",
    "client_id": 1,
    "identifier": "clientIdentifier",
    "roles": [1, 2]
  }
}

Response Fields Description

key value description
code 200000 success. http status will be 201
message Token generated for client 1 result message
content Object The response of the client or user generated token
jwt_token token The generated token
name Subject Name The subject name
description Subject description The subject description
client_id 1 The client id only showed if grant_type is client_credentials
user_id 1 The user id if grant_type is password
identifier clientIdentifier The client identifier if grant_type is client_credentials
username userUsername The user username if grant_type is password
roles [1, 2] The clients or user roles id array

Response codes

code description
400001 Incorrect client secret or user password
400011 Client can not generate short live token
400004 Client or user not found
500000 Not categorized error
Clone this wiki locally