oAuth token exchange results with access_denied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2023 04:27 AM
Greetings,
I am following the documentation, for implementing the oAuth flow (reference), so the authorisation call succeeds and does hit the redirect URL with the required code param. The following step, in order to acquire the access token would be to do the token exchange request:
/oauth_token.do/?grant_type=authorization_code&code={the auth code}&redirect_uri={the_same_redirect_url}&client_id={the_same_client_identifier}&client_secret={client_secret_value})
Here comes the issue, when trying to trigger that endpoint, it fails with a 401:
{
"error_description": "access_denied",
"error": "server_error"
}
I've tried to pass the required params (from endpoint above) via the body with the content type application/x-www-form-urlencoded as well as through the query params.
Why is this not working? Is the documentation outdated?
Further more, the authorisation endpoint:
/oauth_auth.do?response_type=code&redirect_uri={the_redirect_url}&client_id={the_client_identifier}
Requires an additional property code_challenge which is not documented to be required. If not provided the endpoint call fails.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2023 02:37 PM
Hi @sakile ,
Please read this ServiceNow's quick guide as it can help you to understand the process with an example:
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0778194
I've also recorded a video based on that instructions:
Hope this helps,
Pablo