Exchange a code for a key
curl --request POST \
--url https://api.yousonder.com/v1/oauth/token \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data grant_type=authorization_code \
--data 'code=<string>' \
--data 'redirect_uri=<string>' \
--data 'client_id=<string>' \
--data 'client_secret=<string>' \
--data 'code_verifier=<string>'const options = {
method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: new URLSearchParams({
grant_type: 'authorization_code',
code: '<string>',
redirect_uri: '<string>',
client_id: '<string>',
client_secret: '<string>',
code_verifier: '<string>'
})
};
fetch('https://api.yousonder.com/v1/oauth/token', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.yousonder.com/v1/oauth/token"
payload = {
"grant_type": "authorization_code",
"code": "<string>",
"redirect_uri": "<string>",
"client_id": "<string>",
"client_secret": "<string>",
"code_verifier": "<string>"
}
headers = {"Content-Type": "application/x-www-form-urlencoded"}
response = requests.post(url, data=payload, headers=headers)
print(response.text){
"access_token": "sonder_live_q8Zr2mN4xT7vB1cK9pL3sD6fG0hJ5wYe",
"token_type": "Bearer",
"scope": "read",
"account": {
"id": "2c6f9a10-3d4b-4e8f-9a1b-7c5d3e2f1a09",
"email": "jane@example.com"
}
}{
"error": "invalid_grant",
"error_description": "That code has expired (codes last 10 minutes)."
}{
"error": "invalid_client",
"error_description": "Unknown client or wrong client secret."
}One-click connect
Exchange a code for a key
Step 3 of one-click connect. Trade the code Sonder sent back to your redirect_uri for an API key. Codes last 10 minutes and work once. Authenticate with your client ID and secret (HTTP Basic or in the body). Errors follow OAuth 2.0: { "error", "error_description" }.
POST
/
oauth
/
token
Exchange a code for a key
curl --request POST \
--url https://api.yousonder.com/v1/oauth/token \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data grant_type=authorization_code \
--data 'code=<string>' \
--data 'redirect_uri=<string>' \
--data 'client_id=<string>' \
--data 'client_secret=<string>' \
--data 'code_verifier=<string>'const options = {
method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: new URLSearchParams({
grant_type: 'authorization_code',
code: '<string>',
redirect_uri: '<string>',
client_id: '<string>',
client_secret: '<string>',
code_verifier: '<string>'
})
};
fetch('https://api.yousonder.com/v1/oauth/token', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.yousonder.com/v1/oauth/token"
payload = {
"grant_type": "authorization_code",
"code": "<string>",
"redirect_uri": "<string>",
"client_id": "<string>",
"client_secret": "<string>",
"code_verifier": "<string>"
}
headers = {"Content-Type": "application/x-www-form-urlencoded"}
response = requests.post(url, data=payload, headers=headers)
print(response.text){
"access_token": "sonder_live_q8Zr2mN4xT7vB1cK9pL3sD6fG0hJ5wYe",
"token_type": "Bearer",
"scope": "read",
"account": {
"id": "2c6f9a10-3d4b-4e8f-9a1b-7c5d3e2f1a09",
"email": "jane@example.com"
}
}{
"error": "invalid_grant",
"error_description": "That code has expired (codes last 10 minutes)."
}{
"error": "invalid_client",
"error_description": "Unknown client or wrong client secret."
}Body
application/x-www-form-urlencodedapplication/json
Allowed value:
"authorization_code"The code Sonder sent to your redirect_uri.
Exactly the one you sent the author with.
Or send it with HTTP Basic auth.
Or send it with HTTP Basic auth.
Required if you sent a code_challenge (PKCE).