Generar Access Token
curl --request POST \
--url https://auth.preprod.alignet.io/token \
--header 'ALG-API-VERSION: <alg-api-version>' \
--header 'Content-Type: application/json' \
--data '
{
"action": "authorize",
"grant_type": "client_credentials",
"audience": "https://api.preprod.alignet.io/",
"client_id": "your_client_id",
"client_secret": "your_client_secret",
"scope": "create:token post:charges get:charges delete:charges"
}
'import requests
url = "https://auth.preprod.alignet.io/token"
payload = {
"action": "authorize",
"grant_type": "client_credentials",
"audience": "https://api.preprod.alignet.io/",
"client_id": "your_client_id",
"client_secret": "your_client_secret",
"scope": "create:token post:charges get:charges delete:charges"
}
headers = {
"ALG-API-VERSION": "<alg-api-version>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'ALG-API-VERSION': '<alg-api-version>', 'Content-Type': 'application/json'},
body: JSON.stringify({
action: 'authorize',
grant_type: 'client_credentials',
audience: 'https://api.preprod.alignet.io/',
client_id: 'your_client_id',
client_secret: 'your_client_secret',
scope: 'create:token post:charges get:charges delete:charges'
})
};
fetch('https://auth.preprod.alignet.io/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://auth.preprod.alignet.io/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([
'action' => 'authorize',
'grant_type' => 'client_credentials',
'audience' => 'https://api.preprod.alignet.io/',
'client_id' => 'your_client_id',
'client_secret' => 'your_client_secret',
'scope' => 'create:token post:charges get:charges delete:charges'
]),
CURLOPT_HTTPHEADER => [
"ALG-API-VERSION: <alg-api-version>",
"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://auth.preprod.alignet.io/token"
payload := strings.NewReader("{\n \"action\": \"authorize\",\n \"grant_type\": \"client_credentials\",\n \"audience\": \"https://api.preprod.alignet.io/\",\n \"client_id\": \"your_client_id\",\n \"client_secret\": \"your_client_secret\",\n \"scope\": \"create:token post:charges get:charges delete:charges\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("ALG-API-VERSION", "<alg-api-version>")
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://auth.preprod.alignet.io/token")
.header("ALG-API-VERSION", "<alg-api-version>")
.header("Content-Type", "application/json")
.body("{\n \"action\": \"authorize\",\n \"grant_type\": \"client_credentials\",\n \"audience\": \"https://api.preprod.alignet.io/\",\n \"client_id\": \"your_client_id\",\n \"client_secret\": \"your_client_secret\",\n \"scope\": \"create:token post:charges get:charges delete:charges\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://auth.preprod.alignet.io/token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["ALG-API-VERSION"] = '<alg-api-version>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"action\": \"authorize\",\n \"grant_type\": \"client_credentials\",\n \"audience\": \"https://api.preprod.alignet.io/\",\n \"client_id\": \"your_client_id\",\n \"client_secret\": \"your_client_secret\",\n \"scope\": \"create:token post:charges get:charges delete:charges\"\n}"
response = http.request(request)
puts response.read_body{
"action": "authorize",
"success": true,
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9...",
"scope": "create:token api-test:create:token",
"expires_in": 8600,
"token_type": "Bearer",
"authorization": {
"meta": {
"status": {
"code": "00",
"message_ilgn": [
{
"locale": "es_PE",
"value": "Access Token creado"
}
]
}
}
}
}Authentication
Generar Access Token
Genera un Bearer Token usando credenciales del comercio y el flujo client_credentials.
Si prefieres ver la solicitud documentada paso a paso, revisa Autenticación.
POST
/
token
Generar Access Token
curl --request POST \
--url https://auth.preprod.alignet.io/token \
--header 'ALG-API-VERSION: <alg-api-version>' \
--header 'Content-Type: application/json' \
--data '
{
"action": "authorize",
"grant_type": "client_credentials",
"audience": "https://api.preprod.alignet.io/",
"client_id": "your_client_id",
"client_secret": "your_client_secret",
"scope": "create:token post:charges get:charges delete:charges"
}
'import requests
url = "https://auth.preprod.alignet.io/token"
payload = {
"action": "authorize",
"grant_type": "client_credentials",
"audience": "https://api.preprod.alignet.io/",
"client_id": "your_client_id",
"client_secret": "your_client_secret",
"scope": "create:token post:charges get:charges delete:charges"
}
headers = {
"ALG-API-VERSION": "<alg-api-version>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'ALG-API-VERSION': '<alg-api-version>', 'Content-Type': 'application/json'},
body: JSON.stringify({
action: 'authorize',
grant_type: 'client_credentials',
audience: 'https://api.preprod.alignet.io/',
client_id: 'your_client_id',
client_secret: 'your_client_secret',
scope: 'create:token post:charges get:charges delete:charges'
})
};
fetch('https://auth.preprod.alignet.io/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://auth.preprod.alignet.io/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([
'action' => 'authorize',
'grant_type' => 'client_credentials',
'audience' => 'https://api.preprod.alignet.io/',
'client_id' => 'your_client_id',
'client_secret' => 'your_client_secret',
'scope' => 'create:token post:charges get:charges delete:charges'
]),
CURLOPT_HTTPHEADER => [
"ALG-API-VERSION: <alg-api-version>",
"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://auth.preprod.alignet.io/token"
payload := strings.NewReader("{\n \"action\": \"authorize\",\n \"grant_type\": \"client_credentials\",\n \"audience\": \"https://api.preprod.alignet.io/\",\n \"client_id\": \"your_client_id\",\n \"client_secret\": \"your_client_secret\",\n \"scope\": \"create:token post:charges get:charges delete:charges\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("ALG-API-VERSION", "<alg-api-version>")
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://auth.preprod.alignet.io/token")
.header("ALG-API-VERSION", "<alg-api-version>")
.header("Content-Type", "application/json")
.body("{\n \"action\": \"authorize\",\n \"grant_type\": \"client_credentials\",\n \"audience\": \"https://api.preprod.alignet.io/\",\n \"client_id\": \"your_client_id\",\n \"client_secret\": \"your_client_secret\",\n \"scope\": \"create:token post:charges get:charges delete:charges\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://auth.preprod.alignet.io/token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["ALG-API-VERSION"] = '<alg-api-version>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"action\": \"authorize\",\n \"grant_type\": \"client_credentials\",\n \"audience\": \"https://api.preprod.alignet.io/\",\n \"client_id\": \"your_client_id\",\n \"client_secret\": \"your_client_secret\",\n \"scope\": \"create:token post:charges get:charges delete:charges\"\n}"
response = http.request(request)
puts response.read_body{
"action": "authorize",
"success": true,
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9...",
"scope": "create:token api-test:create:token",
"expires_in": 8600,
"token_type": "Bearer",
"authorization": {
"meta": {
"status": {
"code": "00",
"message_ilgn": [
{
"locale": "es_PE",
"value": "Access Token creado"
}
]
}
}
}
}Cuerpo
application/json
Respuesta
Token generado correctamente.
Token para usar en las APIs. Antes de consumir endpoints protegidos, puedes revisar la solicitud del token en Autenticación.
Ejemplo:
"eyJhbGciOiJIUzI1NiIs..."

