Exchange an authorization code for an access token
curl --request POST \
--url https://api.lojou.app/v1/oauth/token \
--header 'Content-Type: application/json' \
--data '
{
"code": "<string>",
"client_id": "<string>",
"client_secret": "<string>",
"redirect_uri": "<string>",
"state": "<string>"
}
'import requests
url = "https://api.lojou.app/v1/oauth/token"
payload = {
"code": "<string>",
"client_id": "<string>",
"client_secret": "<string>",
"redirect_uri": "<string>",
"state": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
code: '<string>',
client_id: '<string>',
client_secret: '<string>',
redirect_uri: '<string>',
state: '<string>'
})
};
fetch('https://api.lojou.app/v1/oauth/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://api.lojou.app/v1/oauth/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([
'code' => '<string>',
'client_id' => '<string>',
'client_secret' => '<string>',
'redirect_uri' => '<string>',
'state' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"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://api.lojou.app/v1/oauth/token"
payload := strings.NewReader("{\n \"code\": \"<string>\",\n \"client_id\": \"<string>\",\n \"client_secret\": \"<string>\",\n \"redirect_uri\": \"<string>\",\n \"state\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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://api.lojou.app/v1/oauth/token")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"<string>\",\n \"client_id\": \"<string>\",\n \"client_secret\": \"<string>\",\n \"redirect_uri\": \"<string>\",\n \"state\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.lojou.app/v1/oauth/token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"code\": \"<string>\",\n \"client_id\": \"<string>\",\n \"client_secret\": \"<string>\",\n \"redirect_uri\": \"<string>\",\n \"state\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"access_token": "aB3xY9k2mZ7...",
"refresh_token": "rT8pL1qN4wV...",
"token_type": "Bearer",
"expires_in": 2592000,
"expires_at": "2026-09-30T12:00:00.000000Z",
"permissions": [
"orders.read",
"products.read"
]
}{
"status": "error",
"message": "Código inválido ou expirado"
}{
"status": "error",
"message": "Validation failed.",
"errors": {
"amount": [
"The amount field is required."
]
}
}OAuth
Exchange an authorization code for an access token
Second step of the OAuth flow: exchange the code your app received
on the redirect callback for a long-lived access token. The code
is single-use and expires 10 minutes after the store owner
authorizes your app. See the OAuth guide for the full flow
(registering an app, sending the seller to authorize, and handling
the callback).
POST
/
v1
/
oauth
/
token
Exchange an authorization code for an access token
curl --request POST \
--url https://api.lojou.app/v1/oauth/token \
--header 'Content-Type: application/json' \
--data '
{
"code": "<string>",
"client_id": "<string>",
"client_secret": "<string>",
"redirect_uri": "<string>",
"state": "<string>"
}
'import requests
url = "https://api.lojou.app/v1/oauth/token"
payload = {
"code": "<string>",
"client_id": "<string>",
"client_secret": "<string>",
"redirect_uri": "<string>",
"state": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
code: '<string>',
client_id: '<string>',
client_secret: '<string>',
redirect_uri: '<string>',
state: '<string>'
})
};
fetch('https://api.lojou.app/v1/oauth/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://api.lojou.app/v1/oauth/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([
'code' => '<string>',
'client_id' => '<string>',
'client_secret' => '<string>',
'redirect_uri' => '<string>',
'state' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"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://api.lojou.app/v1/oauth/token"
payload := strings.NewReader("{\n \"code\": \"<string>\",\n \"client_id\": \"<string>\",\n \"client_secret\": \"<string>\",\n \"redirect_uri\": \"<string>\",\n \"state\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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://api.lojou.app/v1/oauth/token")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"<string>\",\n \"client_id\": \"<string>\",\n \"client_secret\": \"<string>\",\n \"redirect_uri\": \"<string>\",\n \"state\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.lojou.app/v1/oauth/token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"code\": \"<string>\",\n \"client_id\": \"<string>\",\n \"client_secret\": \"<string>\",\n \"redirect_uri\": \"<string>\",\n \"state\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"access_token": "aB3xY9k2mZ7...",
"refresh_token": "rT8pL1qN4wV...",
"token_type": "Bearer",
"expires_in": 2592000,
"expires_at": "2026-09-30T12:00:00.000000Z",
"permissions": [
"orders.read",
"products.read"
]
}{
"status": "error",
"message": "Código inválido ou expirado"
}{
"status": "error",
"message": "Validation failed.",
"errors": {
"amount": [
"The amount field is required."
]
}
}Corpo
application/json
Authorization code received on the redirect callback after the seller approved your app.
Must match exactly the redirect_uri your app was registered with.
The same state value that came back with the authorization code, echoed back for CSRF protection.
Resposta
Token issued
