Create M2M access token
curl --request POST \
--url https://{defaultHost}/v1/apps/{app_id}/m2m/token \
--header 'Authorization: Bearer <token>'import requests
url = "https://{defaultHost}/v1/apps/{app_id}/m2m/token"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://{defaultHost}/v1/apps/{app_id}/m2m/token', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{defaultHost}/v1/apps/{app_id}/m2m/token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://{defaultHost}/v1/apps/{app_id}/m2m/token"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{defaultHost}/v1/apps/{app_id}/m2m/token")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://{defaultHost}/v1/apps/{app_id}/m2m/token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"access": "<string>",
"access_expires_at": "2023-11-07T05:31:56Z",
"csrf": "<string>",
"key_id": "<string>",
"client_name": "<string>",
"refresh": "<string>",
"refresh_expires_at": "2023-11-07T05:31:56Z"
}{
"error": "Client name required",
"error_code": "<string>"
}{
"error": "API key not authorized for this app",
"error_code": "<string>"
}{
"error": "App not found",
"error_code": "app_not_found"
}{
"error": "Failed to create M2M token",
"error_code": "<string>"
}M2M Sessions
Create M2M access token
Create a machine-to-machine session and return long-lived JWT credentials
POST
/
v1
/
apps
/
{app_id}
/
m2m
/
token
Create M2M access token
curl --request POST \
--url https://{defaultHost}/v1/apps/{app_id}/m2m/token \
--header 'Authorization: Bearer <token>'import requests
url = "https://{defaultHost}/v1/apps/{app_id}/m2m/token"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://{defaultHost}/v1/apps/{app_id}/m2m/token', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{defaultHost}/v1/apps/{app_id}/m2m/token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://{defaultHost}/v1/apps/{app_id}/m2m/token"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{defaultHost}/v1/apps/{app_id}/m2m/token")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://{defaultHost}/v1/apps/{app_id}/m2m/token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"access": "<string>",
"access_expires_at": "2023-11-07T05:31:56Z",
"csrf": "<string>",
"key_id": "<string>",
"client_name": "<string>",
"refresh": "<string>",
"refresh_expires_at": "2023-11-07T05:31:56Z"
}{
"error": "Client name required",
"error_code": "<string>"
}{
"error": "API key not authorized for this app",
"error_code": "<string>"
}{
"error": "App not found",
"error_code": "app_not_found"
}{
"error": "Failed to create M2M token",
"error_code": "<string>"
}Authorizations
API Secret token
Path Parameters
App ID
Response
successful
JWT access token
Timestamp when the access token expires
CSRF token required for stateful clients using cookies
Identifier of the signing key used to mint the JWT
Echo of the client name that owns the token
Refresh token, present when the app allows refresh payloads
Timestamp when the refresh token expires
Was this page helpful?