OAuth 2.0 with authorization code not working?

bbarber9
Giga Expert

Hello all, I am running into issues when trying to set up an OAuth 2.0 connection with an authorization code. I have created the application registry and profiles etc. But when I try to get a token it breaks during the flow. I attached a screenshot of where it fails. I think the problem is that servicenow is generating a bad URL during the flow. It has an empty query parameter that I highlighted in the image. Has anyone experienced similar issues/do you have a workaround?

1 ACCEPTED SOLUTION

bbarber9
Giga Expert

Just in case anyone else has this issue, I confirmed it was a bug in ServiceNow with support. Apparently it is not slated to be fixed until the Kingston release 😕



In the mean time, I was able to work around the issue by copying the URL from the popup box and correcting the URL so that the "?&" became just "?" and then manually visiting that URL in my browser.


View solution in original post

6 REPLIES 6

Gopal Harbola1
Tera Expert

Hi







I hope this helps 🙂


PS: Hit like, Helpful or Correct depending on the impact of the response


The server is not down. I have confirmed that it works using other tools to hit the API.


Ankur Bawiskar
Tera Patron
Tera Patron

Hi Barber,



So you want the third party to authenticate with OAuth and hence created OAuth Provider in your instance. You need to give them client_id, client_secret, grant_type, username and password



First step for the third party is to get the access token and then hit the actual api



https://instanceName.service-now.com/oauth_token.do



Below comments from my side related to OAuth



OAuth2.0 without username and password


grant type in OAuth2 with postman


Outbound REST web service call using oAuth



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Thank you for your reply.



The API I am using does not use a username and password. It uses an authorization code flow instead. I have already configured the client_id and client_secret. I have confirmed that all of the parameters do work in Postman. The problem is that when ServiceNow attempts the OAuth flow it generates a URL that does not work correctly. I have confirmed this is a bug with ServiceNow support. Now I am trying to find out if anyone has found a workaround.