Authenticate user and obtain access token
curl --request POST \
--url https://reimagined-journey-g45xxv4v6gwhvrrr-80.app.github.dev/auth/token \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"grant_type": "password",
"user_name": "john_doe",
"password": "P@ssw0rd!"
}
'import requests
url = "https://reimagined-journey-g45xxv4v6gwhvrrr-80.app.github.dev/auth/token"
payload = {
"grant_type": "password",
"user_name": "john_doe",
"password": "P@ssw0rd!"
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({grant_type: 'password', user_name: 'john_doe', password: 'P@ssw0rd!'})
};
fetch('https://reimagined-journey-g45xxv4v6gwhvrrr-80.app.github.dev/auth/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://reimagined-journey-g45xxv4v6gwhvrrr-80.app.github.dev/auth/token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'grant_type' => 'password',
'user_name' => 'john_doe',
'password' => 'P@ssw0rd!'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://reimagined-journey-g45xxv4v6gwhvrrr-80.app.github.dev/auth/token"
payload := strings.NewReader("{\n \"grant_type\": \"password\",\n \"user_name\": \"john_doe\",\n \"password\": \"P@ssw0rd!\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://reimagined-journey-g45xxv4v6gwhvrrr-80.app.github.dev/auth/token")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"grant_type\": \"password\",\n \"user_name\": \"john_doe\",\n \"password\": \"P@ssw0rd!\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://reimagined-journey-g45xxv4v6gwhvrrr-80.app.github.dev/auth/token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"grant_type\": \"password\",\n \"user_name\": \"john_doe\",\n \"password\": \"P@ssw0rd!\"\n}"
response = http.request(request)
puts response.read_body{
"auth_id": "674d0bf5c28b69001f8e03a1",
"created_at": "2024-04-22T10:00:00Z",
"updated_at": "2024-04-22T10:00:00Z",
"access_token": "fa0b97b2-445f-41d2-b50f-fb3b014a301e",
"expires_at": "2024-04-22T10:00:00Z",
"refresh_token": "d1a3e281-96b6-4f77-a587-7b6c8c2a96d9",
"token_type": "Bearer",
"user_name": "john_doe"
}{
"title": "Human-readable error title.",
"detail": "Human-readable error details."
}{
"title": "Human-readable error title.",
"detail": "Human-readable error details."
}Auth
Authenticate user and obtain access token
Exchange the user’s username and password for an access token.
The client ID and client secret are used for client authentication (basic). Certain endpoints require the access token in the Authorization header to perform admin functions, like creating menus.
If an existing access token is associated with the user, it will be invalidated before a new one is generated.
POST
/
auth
/
token
Authenticate user and obtain access token
curl --request POST \
--url https://reimagined-journey-g45xxv4v6gwhvrrr-80.app.github.dev/auth/token \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"grant_type": "password",
"user_name": "john_doe",
"password": "P@ssw0rd!"
}
'import requests
url = "https://reimagined-journey-g45xxv4v6gwhvrrr-80.app.github.dev/auth/token"
payload = {
"grant_type": "password",
"user_name": "john_doe",
"password": "P@ssw0rd!"
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({grant_type: 'password', user_name: 'john_doe', password: 'P@ssw0rd!'})
};
fetch('https://reimagined-journey-g45xxv4v6gwhvrrr-80.app.github.dev/auth/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://reimagined-journey-g45xxv4v6gwhvrrr-80.app.github.dev/auth/token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'grant_type' => 'password',
'user_name' => 'john_doe',
'password' => 'P@ssw0rd!'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://reimagined-journey-g45xxv4v6gwhvrrr-80.app.github.dev/auth/token"
payload := strings.NewReader("{\n \"grant_type\": \"password\",\n \"user_name\": \"john_doe\",\n \"password\": \"P@ssw0rd!\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://reimagined-journey-g45xxv4v6gwhvrrr-80.app.github.dev/auth/token")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"grant_type\": \"password\",\n \"user_name\": \"john_doe\",\n \"password\": \"P@ssw0rd!\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://reimagined-journey-g45xxv4v6gwhvrrr-80.app.github.dev/auth/token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"grant_type\": \"password\",\n \"user_name\": \"john_doe\",\n \"password\": \"P@ssw0rd!\"\n}"
response = http.request(request)
puts response.read_body{
"auth_id": "674d0bf5c28b69001f8e03a1",
"created_at": "2024-04-22T10:00:00Z",
"updated_at": "2024-04-22T10:00:00Z",
"access_token": "fa0b97b2-445f-41d2-b50f-fb3b014a301e",
"expires_at": "2024-04-22T10:00:00Z",
"refresh_token": "d1a3e281-96b6-4f77-a587-7b6c8c2a96d9",
"token_type": "Bearer",
"user_name": "john_doe"
}{
"title": "Human-readable error title.",
"detail": "Human-readable error details."
}{
"title": "Human-readable error title.",
"detail": "Human-readable error details."
}Body
application/json
The request body to create a token requires the following properties: grant_type, user_name, and password.
Response
Resource created successfully. The response body contains the newly created resource.
The response object returned for both /auth endpoints.