How am I supposed to authorize an API call to create a new session with OAuth? I have gone through the steps to generate an access token, but I am always returned 401 ( "You are not authenticated. Authentication required to perform this operation." )
my call:
$.ajax ({
url: "https://myjira.com/rest/auth/1/session",
type: 'GET',
beforeSend: function(xhr) {
xhr.setRequestHeader("Authorization", "Bearer <accesstoken>");xhr.withCredentials = true;
},
success: function(response) {
alert("success");
},
error: function(error) {
alert("error");
}});
Doing this same call using basic authentication works fine, such as:
var username = $("#username").val();
var password = $("#password").val();
$.ajax ({
url: "https://myjira.com/rest/auth/1/session",
type: 'GET',
beforeSend: function(xhr) {
var base64 = btoa(username + ':' + password);
xhr.setRequestHeader("Authorization", "Basic " + base64);
xhr.withCredentials = true;
},
success: function(response) {
alert("success");
},
error: function(error) {
alert("error");
}
});
How am I supposed to authorize this call for a new session using oauth? I've spent days now searching for a working example with no luck. Thanks!
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.