Account & Auth
Exchange an OAuth code or refresh token
Developer API operation for POST /dev/v1/oauth/token.
POST
/
dev
/
v1
/
oauth
/
token
Exchange an OAuth code or refresh token
curl --request POST \
--url https://api.shoppex.io/dev/v1/oauth/token \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data grant_type=authorization_code \
--data code=shoa_code_1 \
--data redirect_uri=https://erp.example.com/callback \
--data client_id=shoc_demo \
--data client_secret=shcs_secretconst options = {
method: 'POST',
headers: {
Authorization: 'Bearer <token>',
'Content-Type': 'application/x-www-form-urlencoded'
},
body: new URLSearchParams({
grant_type: 'authorization_code',
code: 'shoa_code_1',
redirect_uri: 'https://erp.example.com/callback',
client_id: 'shoc_demo',
client_secret: 'shcs_secret'
})
};
fetch('https://api.shoppex.io/dev/v1/oauth/token', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.shoppex.io/dev/v1/oauth/token"
payload = {
"grant_type": "authorization_code",
"code": "shoa_code_1",
"redirect_uri": "https://erp.example.com/callback",
"client_id": "shoc_demo",
"client_secret": "shcs_secret"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/x-www-form-urlencoded"
}
response = requests.post(url, data=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.shoppex.io/dev/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 => "grant_type=authorization_code&code=shoa_code_1&redirect_uri=https%3A%2F%2Ferp.example.com%2Fcallback&client_id=shoc_demo&client_secret=shcs_secret",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/x-www-form-urlencoded"
],
]);
$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.shoppex.io/dev/v1/oauth/token"
payload := strings.NewReader("grant_type=authorization_code&code=shoa_code_1&redirect_uri=https%3A%2F%2Ferp.example.com%2Fcallback&client_id=shoc_demo&client_secret=shcs_secret")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"access_token": "shpat_access_1",
"token_type": "Bearer",
"expires_in": 3600,
"refresh_token": "shprt_refresh_1",
"scope": "orders.read customers.read"
}⌘I
Exchange an OAuth code or refresh token
curl --request POST \
--url https://api.shoppex.io/dev/v1/oauth/token \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data grant_type=authorization_code \
--data code=shoa_code_1 \
--data redirect_uri=https://erp.example.com/callback \
--data client_id=shoc_demo \
--data client_secret=shcs_secretconst options = {
method: 'POST',
headers: {
Authorization: 'Bearer <token>',
'Content-Type': 'application/x-www-form-urlencoded'
},
body: new URLSearchParams({
grant_type: 'authorization_code',
code: 'shoa_code_1',
redirect_uri: 'https://erp.example.com/callback',
client_id: 'shoc_demo',
client_secret: 'shcs_secret'
})
};
fetch('https://api.shoppex.io/dev/v1/oauth/token', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.shoppex.io/dev/v1/oauth/token"
payload = {
"grant_type": "authorization_code",
"code": "shoa_code_1",
"redirect_uri": "https://erp.example.com/callback",
"client_id": "shoc_demo",
"client_secret": "shcs_secret"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/x-www-form-urlencoded"
}
response = requests.post(url, data=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.shoppex.io/dev/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 => "grant_type=authorization_code&code=shoa_code_1&redirect_uri=https%3A%2F%2Ferp.example.com%2Fcallback&client_id=shoc_demo&client_secret=shcs_secret",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/x-www-form-urlencoded"
],
]);
$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.shoppex.io/dev/v1/oauth/token"
payload := strings.NewReader("grant_type=authorization_code&code=shoa_code_1&redirect_uri=https%3A%2F%2Ferp.example.com%2Fcallback&client_id=shoc_demo&client_secret=shcs_secret")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"access_token": "shpat_access_1",
"token_type": "Bearer",
"expires_in": 3600,
"refresh_token": "shprt_refresh_1",
"scope": "orders.read customers.read"
}