Obtain an access token
curl --request POST \
--url https://api.ridergy.com/v1/oauth/token \
--header 'Content-Type: application/json' \
--data '
{
"grant_type": "client_credentials",
"client_id": "emcl_a1b2c3d4e5f67890a1b2c3d4e5f67890",
"client_secret": "emcs_a1b2c3d4..."
}
'import requests
url = "https://api.ridergy.com/v1/oauth/token"
payload = {
"grant_type": "client_credentials",
"client_id": "emcl_a1b2c3d4e5f67890a1b2c3d4e5f67890",
"client_secret": "emcs_a1b2c3d4..."
}
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({
grant_type: 'client_credentials',
client_id: 'emcl_a1b2c3d4e5f67890a1b2c3d4e5f67890',
client_secret: 'emcs_a1b2c3d4...'
})
};
fetch('https://api.ridergy.com/v1/oauth/token', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.ridergy.com/v1/oauth/token"
payload := strings.NewReader("{\n \"grant_type\": \"client_credentials\",\n \"client_id\": \"emcl_a1b2c3d4e5f67890a1b2c3d4e5f67890\",\n \"client_secret\": \"emcs_a1b2c3d4...\"\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))
}<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ridergy.com/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([
'grant_type' => 'client_credentials',
'client_id' => 'emcl_a1b2c3d4e5f67890a1b2c3d4e5f67890',
'client_secret' => 'emcs_a1b2c3d4...'
]),
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;
}HttpResponse<String> response = Unirest.post("https://api.ridergy.com/v1/oauth/token")
.header("Content-Type", "application/json")
.body("{\n \"grant_type\": \"client_credentials\",\n \"client_id\": \"emcl_a1b2c3d4e5f67890a1b2c3d4e5f67890\",\n \"client_secret\": \"emcs_a1b2c3d4...\"\n}")
.asString();{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"token_type": "Bearer",
"expires_in": 3600,
"scope": "locations:read locations:write clusters:read clusters:write chargers:write org:write"
}{
"error": "unsupported_grant_type",
"error_description": "Only client_credentials grant type is supported"
}{
"error": "invalid_client",
"error_description": "Invalid client credentials"
}Authentification
Obtenir un jeton d'accès
Échange des identifiants client contre un jeton Bearer de courte durée (3600s).
Accepte les identifiants via :
Authorization: Basic base64(client_id:client_secret)avecgrant_type=client_credentialsdans le corps de la requête (RFC 6749)- Corps JSON avec
client_id,client_secretetgrant_type
POST
/
oauth
/
token
Obtain an access token
curl --request POST \
--url https://api.ridergy.com/v1/oauth/token \
--header 'Content-Type: application/json' \
--data '
{
"grant_type": "client_credentials",
"client_id": "emcl_a1b2c3d4e5f67890a1b2c3d4e5f67890",
"client_secret": "emcs_a1b2c3d4..."
}
'import requests
url = "https://api.ridergy.com/v1/oauth/token"
payload = {
"grant_type": "client_credentials",
"client_id": "emcl_a1b2c3d4e5f67890a1b2c3d4e5f67890",
"client_secret": "emcs_a1b2c3d4..."
}
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({
grant_type: 'client_credentials',
client_id: 'emcl_a1b2c3d4e5f67890a1b2c3d4e5f67890',
client_secret: 'emcs_a1b2c3d4...'
})
};
fetch('https://api.ridergy.com/v1/oauth/token', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.ridergy.com/v1/oauth/token"
payload := strings.NewReader("{\n \"grant_type\": \"client_credentials\",\n \"client_id\": \"emcl_a1b2c3d4e5f67890a1b2c3d4e5f67890\",\n \"client_secret\": \"emcs_a1b2c3d4...\"\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))
}<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ridergy.com/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([
'grant_type' => 'client_credentials',
'client_id' => 'emcl_a1b2c3d4e5f67890a1b2c3d4e5f67890',
'client_secret' => 'emcs_a1b2c3d4...'
]),
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;
}HttpResponse<String> response = Unirest.post("https://api.ridergy.com/v1/oauth/token")
.header("Content-Type", "application/json")
.body("{\n \"grant_type\": \"client_credentials\",\n \"client_id\": \"emcl_a1b2c3d4e5f67890a1b2c3d4e5f67890\",\n \"client_secret\": \"emcs_a1b2c3d4...\"\n}")
.asString();{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"token_type": "Bearer",
"expires_in": 3600,
"scope": "locations:read locations:write clusters:read clusters:write chargers:write org:write"
}{
"error": "unsupported_grant_type",
"error_description": "Only client_credentials grant type is supported"
}{
"error": "invalid_client",
"error_description": "Invalid client credentials"
}Corps
application/json
Réponse
Jeton d'accès émis
Jeton Bearer JWT
Exemple:
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
Exemple:
"Bearer"
Durée de vie du jeton en secondes
Exemple:
3600
Liste des scopes accordés séparés par des espaces
Exemple:
"locations:read locations:write clusters:read clusters:write chargers:write org:write"

