401 Unauthorized error when trying to get OAuth token via AJAX
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2016 05:04 AM
I'm getting 401 Unauthorized error too when using API in development instance (Helsinki). Under roles, rest_service role description says "Deprecated. This role is no longer required to access the REST API." When creating the user I'm using to connect, I did make sure it has "Web service access only" checkbox checked.
$(document).ready(function () {
//get token
var snOauthClientId = 'my_client_id';
var snOauthSecret = 'my_secret';
$.ajax({
url: 'https://dev_instance.service-now.com/oauth_token.do?grant_type=password&client_id=' + snOauthClientId + '&client_secret=' + snOauthSecret,
type: 'POST',
dataType: 'jsonp',
success: function (data) { console.log(JSON.stringify(data)); },
beforeSend: setHeader,
error: function () { alert('Failed!'); }//this line gets called; browser's developer tools message displays the 401 error
});
});
function setHeader(xhr) {
var snRESTUser = 'username';
var snRESTPwd = 'password';
xhr.setRequestHeader("Authorization", "Basic " + btoa(snRESTUser + ":" + snRESTPwd));
xhr.setRequestHeader('Accept', 'application/json');
xhr.setRequestHeader('Content-Type', 'application/json');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2016 09:29 AM
Chuck do you have an approx. idea on when the next release is coming?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2016 11:40 AM
Istanbul is coming in Q4 of this year (really really soon.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2024 05:19 AM
Hi @Chuck Tomasi and @greatbear302 now after 8 years is possible for how solve it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-28-2023 08:31 AM
Are you able to resolve this?