Get Oauth token gives HTTP Error 401 - Unauthorized

Khalnayak
Tera Guru

Hi all,

I have created an app registry for the Service Graph Connector for Microsoft Intune app in ServiceNow.

I have created an app registry in azure too and all the setup looks fine.

But when clicking on Get Oauth token I  am getting the HTTP Error 401 - Unauthorized.

I dont know why though, as I have the exact same setup for my dev instance and that is working fine.

Just when setting it up in test it is giving this error.

The only  difference between the 2 instances that I know of, is that test is SSO using Azure AD and Dev is not.

When i first clicked Get Oauth token, it asked me to login, then asked for admin approval, which I got an admin user to enter, and after that I am seeing this error.

 

find_real_file.png

 

Can someone advise please?

find_real_file.png

1 ACCEPTED SOLUTION

shawna
Tera Guru

I had the same issue and this link really helped me. https://www.linkedin.com/pulse/servicenow-outbound-web-services-oauth-20-how-handle-r%C3%A9da-osseili/

 

The error that SN returned by default is very misleading since it hides the actual detailed error message. We need to add some logs in the script include (OAuthUtil) that parse the get token response, so we can understand the exact issue. 

 

My particular issue was that I was using the wrong client secret. I used the id instead of the actual secret value. Silly me, I know!

 

Once you enable the log in OAuthUtil, The error message was able to lead me to resolve my issue. 

 

Hope this will help someone in the future. 

 

View solution in original post

25 REPLIES 25

Thanks for this. Funny how i made this exact mistake now. Used the secret ID instead of secret value. 

FIn1
Tera Contributor

Same error, like mentioned above the wrong secret was provided. 

Mark Roethof
Tera Patron
Tera Patron

Hi there,

"I have the exact same setup for my dev instance"

Have you checked the settings within Intune itself? Recently I've been working also on Intune, and you have to specify the exact environment you are granting access too.

Kind regards,
Mark

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Sumedh Kharode1
Kilo Expert

Hi Team,

I am getting the  error while accessing Oauth access token from servicenow instance as below

{"error_description":"access_denied","error":"server_error"}

I have created OAuth End Point on another instance having below client_id and client_secret

URL = https://customer_instance.service-now.com/oauth_token.do

client_id = 0fa6dade7b000110abfbf53e56d948ff

client_secret = ]Uvyq{wfz`

Content-type = application/x-www-form-urlencoded

grant_type = password

with username & password

 

I checked the username and password by using /login.do and it's working so I think my password is correct

 

Please do the needful

Have you resolved this issue? I'm in the same boat now I'm doing an ajax call its working from post man but not from my custom website where I'm doing an ajax call. Any help?