useGrant
Access Tokens

Create access token

Create a new access token for a client.

POST
/v1/providers/{providerId}/clients/{clientId}/tokens

Authorization

AuthorizationBearer <token>

In: header

Request Body

application/jsonOptional
expiresIn?number

The expiration date and time of the access token in seconds. Cannot be more than 48 hours. The shorter the duration, the more secure it is.

useJwtType?boolean

When true, the access token header type will be set to jwt instead of at+jwt.

audienceAsArray?boolean

When true, the audience will be set as an array instead of a string.

forceDefaultDomain?boolean

When true, the default domain will be used in the issuer field.

Path Parameters

providerIdstring

Unique identifier for a provider.

Format"uuid"
clientIdstring

Unique identifier for a client.

Format"uuid"

Response Body

Token created successfully.

TypeScript Definitions

Use the response body type in TypeScript.

accessTokenstring

JWT token.

expiresAtstring

Expiration date and time of the access token.

typestring

Type of the token.

Invalid request parameters.

TypeScript Definitions

Use the response body type in TypeScript.

codestring
messagestring

Missing or invalid or expired auth token.

TypeScript Definitions

Use the response body type in TypeScript.

codestring
messagestring

Resource not found.

TypeScript Definitions

Use the response body type in TypeScript.

codestring
messagestring

Internal server error.

TypeScript Definitions

Use the response body type in TypeScript.

codestring
messagestring
curl -X POST "https://sdk.usegrant.dev/v1/providers/497f6eca-6276-4993-bfeb-53cbbbba6f08/clients/497f6eca-6276-4993-bfeb-53cbbbba6f08/tokens" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "expiresIn": 0,
    "useJwtType": true,
    "audienceAsArray": true,
    "forceDefaultDomain": true
  }'
const body = JSON.stringify({
  "expiresIn": 0,
  "useJwtType": true,
  "audienceAsArray": true,
  "forceDefaultDomain": true
})

fetch("https://sdk.usegrant.dev/v1/providers/497f6eca-6276-4993-bfeb-53cbbbba6f08/clients/497f6eca-6276-4993-bfeb-53cbbbba6f08/tokens", {
  headers: {
    "Authorization": "Bearer <token>"
  },
  body
})
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
  "strings"
)

func main() {
  url := "https://sdk.usegrant.dev/v1/providers/497f6eca-6276-4993-bfeb-53cbbbba6f08/clients/497f6eca-6276-4993-bfeb-53cbbbba6f08/tokens"
  body := strings.NewReader(`{
    "expiresIn": 0,
    "useJwtType": true,
    "audienceAsArray": true,
    "forceDefaultDomain": true
  }`)
  req, _ := http.NewRequest("POST", url, body)
  req.Header.Add("Authorization", "Bearer <token>")
  req.Header.Add("Content-Type", "application/json")
  res, _ := http.DefaultClient.Do(req)
  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))
}
import requests

url = "https://sdk.usegrant.dev/v1/providers/497f6eca-6276-4993-bfeb-53cbbbba6f08/clients/497f6eca-6276-4993-bfeb-53cbbbba6f08/tokens"
body = {
  "expiresIn": 0,
  "useJwtType": true,
  "audienceAsArray": true,
  "forceDefaultDomain": true
}
response = requests.request("POST", url, json = body, headers = {
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
})

print(response.text)
{
  "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
  "expiresAt": "2024-01-01T00:00:00Z",
  "type": "Bearer"
}
{
  "code": "string",
  "message": "string"
}
{
  "code": "string",
  "message": "string"
}
{
  "code": "string",
  "message": "string"
}
{
  "code": "string",
  "message": "string"
}