Create an authorization code with PKCE
curl --request POST \
--url https://api.swapnice.com/oauth/authorize \
--header 'Content-Type: application/json' \
--data '
{
"response_type": "code",
"client_id": "swa_client_01HZZZ8KQ2J9X2RW7B8Y4D2FPK",
"redirect_uri": "https://partner.example.com/swapnice/callback",
"code_challenge": "ImpiCd8pp4MveCNnbIS7-GXEtB0xF5HMIDoWqvGA5ig",
"code_challenge_method": "S256",
"customer_id": "sandbox_user_001",
"scope": "connections:write consent:write events:write profile:read",
"state": "sandbox-walkthrough"
}
'const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
response_type: 'code',
client_id: 'swa_client_01HZZZ8KQ2J9X2RW7B8Y4D2FPK',
redirect_uri: 'https://partner.example.com/swapnice/callback',
code_challenge: 'ImpiCd8pp4MveCNnbIS7-GXEtB0xF5HMIDoWqvGA5ig',
code_challenge_method: 'S256',
customer_id: 'sandbox_user_001',
scope: 'connections:write consent:write events:write profile:read',
state: 'sandbox-walkthrough'
})
};
fetch('https://api.swapnice.com/oauth/authorize', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.swapnice.com/oauth/authorize"
payload = {
"response_type": "code",
"client_id": "swa_client_01HZZZ8KQ2J9X2RW7B8Y4D2FPK",
"redirect_uri": "https://partner.example.com/swapnice/callback",
"code_challenge": "ImpiCd8pp4MveCNnbIS7-GXEtB0xF5HMIDoWqvGA5ig",
"code_challenge_method": "S256",
"customer_id": "sandbox_user_001",
"scope": "connections:write consent:write events:write profile:read",
"state": "sandbox-walkthrough"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"code": "swa_code_01HZZZ9N3K",
"state": "sandbox-walkthrough",
"redirect_uri": "https://partner.example.com/swapnice/callback",
"expires_in": 300
}{
"error": {
"code": "consent_denied",
"message": "<string>",
"request_id": "<string>",
"details": [
{
"code": "<string>",
"message": "<string>",
"field": "<string>"
}
]
}
}OAuth
Create an authorization code
JSON PKCE authorize used by the SDK and sandbox walkthrough.
POST
/
oauth
/
authorize
Create an authorization code with PKCE
curl --request POST \
--url https://api.swapnice.com/oauth/authorize \
--header 'Content-Type: application/json' \
--data '
{
"response_type": "code",
"client_id": "swa_client_01HZZZ8KQ2J9X2RW7B8Y4D2FPK",
"redirect_uri": "https://partner.example.com/swapnice/callback",
"code_challenge": "ImpiCd8pp4MveCNnbIS7-GXEtB0xF5HMIDoWqvGA5ig",
"code_challenge_method": "S256",
"customer_id": "sandbox_user_001",
"scope": "connections:write consent:write events:write profile:read",
"state": "sandbox-walkthrough"
}
'const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
response_type: 'code',
client_id: 'swa_client_01HZZZ8KQ2J9X2RW7B8Y4D2FPK',
redirect_uri: 'https://partner.example.com/swapnice/callback',
code_challenge: 'ImpiCd8pp4MveCNnbIS7-GXEtB0xF5HMIDoWqvGA5ig',
code_challenge_method: 'S256',
customer_id: 'sandbox_user_001',
scope: 'connections:write consent:write events:write profile:read',
state: 'sandbox-walkthrough'
})
};
fetch('https://api.swapnice.com/oauth/authorize', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.swapnice.com/oauth/authorize"
payload = {
"response_type": "code",
"client_id": "swa_client_01HZZZ8KQ2J9X2RW7B8Y4D2FPK",
"redirect_uri": "https://partner.example.com/swapnice/callback",
"code_challenge": "ImpiCd8pp4MveCNnbIS7-GXEtB0xF5HMIDoWqvGA5ig",
"code_challenge_method": "S256",
"customer_id": "sandbox_user_001",
"scope": "connections:write consent:write events:write profile:read",
"state": "sandbox-walkthrough"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"code": "swa_code_01HZZZ9N3K",
"state": "sandbox-walkthrough",
"redirect_uri": "https://partner.example.com/swapnice/callback",
"expires_in": 300
}{
"error": {
"code": "consent_denied",
"message": "<string>",
"request_id": "<string>",
"details": [
{
"code": "<string>",
"message": "<string>",
"field": "<string>"
}
]
}
}JSON PKCE authorize used by the SDK and sandbox walkthrough.
This is the partner-backend flow.
code_challenge_method must be S256. The code expires in about five minutes and is single-use.
See authentication and the request walkthrough.Body
application/json
Available options:
code Required string length:
43 - 128Available options:
S256 Example:
"connections:write consent:write events:write profile:read"
Maximum string length:
512⌘I