curl -X POST https://phosra-api-sandbox-production.up.railway.app/oauth/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=authorization_code&code=sbxauth_QBmKueI14KzQj9PM-2M9naWGkh2OU6WL"const BASE = "https://phosra-api-sandbox-production.up.railway.app"
const res = await fetch(`${BASE}/oauth/token`, {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: new URLSearchParams({ grant_type: "authorization_code", code: "sbxauth_QBmKueI14KzQj9PM-2M9naWGkh2OU6WL" }),
})
const { access_token } = await res.json()
console.log(res.status, access_token) // 200 sbxtok_…
import requests
url = "https://phosra-api-sandbox-production.up.railway.app/oauth/token"
payload = {
"grant_type": "authorization_code",
"code": "sbxauth_…"
}
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://phosra-api-sandbox-production.up.railway.app/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=sbxauth_%E2%80%A6",
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://phosra-api-sandbox-production.up.railway.app/oauth/token"
payload := strings.NewReader("grant_type=authorization_code&code=sbxauth_%E2%80%A6")
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))
}HttpResponse<String> response = Unirest.post("https://phosra-api-sandbox-production.up.railway.app/oauth/token")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/x-www-form-urlencoded")
.body("grant_type=authorization_code&code=sbxauth_%E2%80%A6")
.asString();require 'uri'
require 'net/http'
url = URI("https://phosra-api-sandbox-production.up.railway.app/oauth/token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/x-www-form-urlencoded'
request.body = "grant_type=authorization_code&code=sbxauth_%E2%80%A6"
response = http.request(request)
puts response.read_body{
"access_token": "sbxtok_8zc0PBmNAjyIs3p8B3Y2oxQW2csHHoy1",
"token_type": "Bearer",
"expires_in": 3600,
"scope": "profiles"
}{
"error": "unsupported_grant_type"
}404 page not found
{
"error": "Too Many Requests",
"message": "rate limit exceeded",
"code": 429
}{
"error": "Internal Server Error",
"message": "internal error",
"code": 500
}{
"error": "Bad Gateway",
"message": "downstream provider error",
"code": 502
}{
"error": "Service Unavailable",
"message": "downstream provider unavailable",
"code": 503
}Reference token leg — code → access token (sandbox)
SANDBOX-ONLY. Exchanges an authorization code (any value carrying the sbxauth_ prefix) for an opaque bearer access token. Accepts application/x-www-form-urlencoded or JSON; PKCE code_verifier is accepted and ignored. Stateless. Gated on the Restricted band. Source: internal/ocsshttp/handler_sandbox_oauth.go Token().
curl -X POST https://phosra-api-sandbox-production.up.railway.app/oauth/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=authorization_code&code=sbxauth_QBmKueI14KzQj9PM-2M9naWGkh2OU6WL"const BASE = "https://phosra-api-sandbox-production.up.railway.app"
const res = await fetch(`${BASE}/oauth/token`, {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: new URLSearchParams({ grant_type: "authorization_code", code: "sbxauth_QBmKueI14KzQj9PM-2M9naWGkh2OU6WL" }),
})
const { access_token } = await res.json()
console.log(res.status, access_token) // 200 sbxtok_…
import requests
url = "https://phosra-api-sandbox-production.up.railway.app/oauth/token"
payload = {
"grant_type": "authorization_code",
"code": "sbxauth_…"
}
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://phosra-api-sandbox-production.up.railway.app/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=sbxauth_%E2%80%A6",
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://phosra-api-sandbox-production.up.railway.app/oauth/token"
payload := strings.NewReader("grant_type=authorization_code&code=sbxauth_%E2%80%A6")
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))
}HttpResponse<String> response = Unirest.post("https://phosra-api-sandbox-production.up.railway.app/oauth/token")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/x-www-form-urlencoded")
.body("grant_type=authorization_code&code=sbxauth_%E2%80%A6")
.asString();require 'uri'
require 'net/http'
url = URI("https://phosra-api-sandbox-production.up.railway.app/oauth/token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/x-www-form-urlencoded'
request.body = "grant_type=authorization_code&code=sbxauth_%E2%80%A6"
response = http.request(request)
puts response.read_body{
"access_token": "sbxtok_8zc0PBmNAjyIs3p8B3Y2oxQW2csHHoy1",
"token_type": "Bearer",
"expires_in": 3600,
"scope": "profiles"
}{
"error": "unsupported_grant_type"
}404 page not found
{
"error": "Too Many Requests",
"message": "rate limit exceeded",
"code": 429
}{
"error": "Internal Server Error",
"message": "internal error",
"code": 500
}{
"error": "Bad Gateway",
"message": "downstream provider error",
"code": 502
}{
"error": "Service Unavailable",
"message": "downstream provider unavailable",
"code": 503
}/api/v1), gated on
PHOSRA_ENV==sandbox — 404 elsewhere.sbxauth_ prefix, from
GET /oauth/authorize) for an opaque bearer
access token. Accepts application/x-www-form-urlencoded or JSON. A PKCE code_verifier is
accepted and ignored. Stateless — tokens live one hour.
Worked example
Fully runnable — this leg is unsigned:curl -X POST https://phosra-api-sandbox-production.up.railway.app/oauth/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=authorization_code&code=sbxauth_QBmKueI14KzQj9PM-2M9naWGkh2OU6WL"
const BASE = "https://phosra-api-sandbox-production.up.railway.app"
const res = await fetch(`${BASE}/oauth/token`, {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: new URLSearchParams({ grant_type: "authorization_code", code: "sbxauth_QBmKueI14KzQj9PM-2M9naWGkh2OU6WL" }),
})
const { access_token } = await res.json()
console.log(res.status, access_token) // 200 sbxtok_…
200 response (captured from the hosted sandbox):
{
"access_token": "sbxtok_9xRWtUBLsk1omBYjWWe-20KbCxTO1Noh",
"token_type": "Bearer",
"expires_in": 3600,
"scope": "profiles"
}
grant_type returns 400 unsupported_grant_type; a code without the
sbxauth_ prefix returns 400 invalid_grant. Present the sbxtok_… token to
GET /oauth/profiles.Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
Response
Access token issued.
SANDBOX-ONLY access token from POST /oauth/token. Source: internal/ocsshttp/handler_sandbox_oauth.go Token().
Opaque bearer ("sbxtok_…"). Present it to GET /oauth/profiles.
One of: Bearer.
Bearer Access-token lifetime in seconds (sandbox tokens live one hour).
3600
Granted scope; the reference provider issues the single profiles scope.
"profiles"