Skip to main content
POST
/
v1
/
oauth2
/
token
PHP (SDK)
declare(strict_types=1);

require 'vendor/autoload.php';

use Spaire;
use Spaire\Models\Components;

$sdk = Spaire\Spaire::builder()->build();

$request = new Components\AuthorizationCodeTokenRequest(
    clientId: '<id>',
    clientSecret: '<value>',
    code: '<value>',
    redirectUri: 'https://memorable-season.name',
);

$response = $sdk->oauth2->token(
    request: $request
);

if ($response->tokenResponse !== null) {
    // handle response
}
{
  "access_token": "<string>",
  "token_type": "<string>",
  "expires_in": 123,
  "scope": "<string>",
  "refresh_token": "<string>",
  "id_token": "<string>"
}

Documentation Index

Fetch the complete documentation index at: https://docs.spairehq.com/llms.txt

Use this file to discover all available pages before exploring further.

Body

application/x-www-form-urlencoded
grant_type
string
required
Allowed value: "authorization_code"
client_id
string
required
client_secret
string
required
code
string
required
redirect_uri
string<uri>
required
Required string length: 1 - 2083

Response

200 - application/json

Successful Response

access_token
string
required
token_type
string
required
Allowed value: "Bearer"
expires_in
integer
required
scope
string
required
refresh_token
string | null
id_token
string | null