Exchange or refresh OAuth tokens
curl --request POST \
--url 'https://swapnice-gateway-dev.ceo-cbc.workers.dev/oauth/token?client_secret=' \
--header 'Content-Type: application/json' \
--data '
{
"grant_type": "authorization_code",
"client_id": "swa_client_01HZZZ8KQ2J9X2RW7B8Y4D2FPK",
"client_secret": "swa_secret_example",
"code": "swa_code_01HZZZ9N3K",
"code_verifier": "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",
"redirect_uri": "https://partner.example.com/swapnice/callback"
}
'const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
grant_type: 'authorization_code',
client_id: 'swa_client_01HZZZ8KQ2J9X2RW7B8Y4D2FPK',
client_secret: 'swa_secret_example',
code: 'swa_code_01HZZZ9N3K',
code_verifier: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~',
redirect_uri: 'https://partner.example.com/swapnice/callback'
})
};
fetch('https://swapnice-gateway-dev.ceo-cbc.workers.dev/oauth/token?client_secret=', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://swapnice-gateway-dev.ceo-cbc.workers.dev/oauth/token?client_secret="
payload = {
"grant_type": "authorization_code",
"client_id": "swa_client_01HZZZ8KQ2J9X2RW7B8Y4D2FPK",
"client_secret": "swa_secret_example",
"code": "swa_code_01HZZZ9N3K",
"code_verifier": "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",
"redirect_uri": "https://partner.example.com/swapnice/callback"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"access_token": "swa_at_example",
"token_type": "Bearer",
"expires_in": 900,
"scope": "connections:write consent:write events:write profile:read"
}{
"error": "invalid_request",
"error_description": "<string>",
"error_uri": "<string>"
}{
"error": "invalid_request",
"error_description": "<string>",
"error_uri": "<string>"
}OAuth
Exchange or refresh a token
Trade an authorization code or refresh token for a Bearer access token.
POST
/
oauth
/
token
Exchange or refresh OAuth tokens
curl --request POST \
--url 'https://swapnice-gateway-dev.ceo-cbc.workers.dev/oauth/token?client_secret=' \
--header 'Content-Type: application/json' \
--data '
{
"grant_type": "authorization_code",
"client_id": "swa_client_01HZZZ8KQ2J9X2RW7B8Y4D2FPK",
"client_secret": "swa_secret_example",
"code": "swa_code_01HZZZ9N3K",
"code_verifier": "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",
"redirect_uri": "https://partner.example.com/swapnice/callback"
}
'const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
grant_type: 'authorization_code',
client_id: 'swa_client_01HZZZ8KQ2J9X2RW7B8Y4D2FPK',
client_secret: 'swa_secret_example',
code: 'swa_code_01HZZZ9N3K',
code_verifier: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~',
redirect_uri: 'https://partner.example.com/swapnice/callback'
})
};
fetch('https://swapnice-gateway-dev.ceo-cbc.workers.dev/oauth/token?client_secret=', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://swapnice-gateway-dev.ceo-cbc.workers.dev/oauth/token?client_secret="
payload = {
"grant_type": "authorization_code",
"client_id": "swa_client_01HZZZ8KQ2J9X2RW7B8Y4D2FPK",
"client_secret": "swa_secret_example",
"code": "swa_code_01HZZZ9N3K",
"code_verifier": "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",
"redirect_uri": "https://partner.example.com/swapnice/callback"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"access_token": "swa_at_example",
"token_type": "Bearer",
"expires_in": 900,
"scope": "connections:write consent:write events:write profile:read"
}{
"error": "invalid_request",
"error_description": "<string>",
"error_uri": "<string>"
}{
"error": "invalid_request",
"error_description": "<string>",
"error_uri": "<string>"
}Trade an authorization code or refresh token for a Bearer access token.
Accepts JSON or form-encoded bodies. Access tokens last about 15 minutes. Include
code_verifier for authorization-code exchanges.Authorizations
Form-style client secret authentication for confidential clients where HTTP Basic is unavailable.
Body
application/jsonapplication/x-www-form-urlencoded