-
Re: Pulling my profile from Jive API
emile.senga Jan 4, 2018 11:21 AM (in response to theycallmeflowz)I haven't used this in a long time, but if I am not mistaken, you need to convert your username and password (in the format "username:password") to a base64 token, then include the term "Bearer" in your authorization header.
var token = base64("myusername:mypassword"): // this isn't a native function, you most likely have to write your own or pull one from the interwebs.
xhr.setRequestHeader("Authorization:", "Bearer " + token);
-
Re: Pulling my profile from Jive API
theycallmeflowz Jan 4, 2018 1:00 PM (in response to theycallmeflowz)Yes I saw those examples but Ive not been successful at getting a bearers toke, I have been able to do this in PHP but I still want to do it in JavaScript, can u pls help with getting a token
-
Re: Pulling my profile from Jive API
emile.senga Jan 6, 2018 9:31 AM (in response to theycallmeflowz)Try the below:
var queryURL = "https://community.jivesoftware.com/api/core/v3/people/@me";
var username = "myUsername";
var password = "myPassword";
var token = window.btoa(username + ":" + password);
$.ajax({
url: queryURL,
beforeSend: function(xhr) {
xhr.setRequestHeader("Authorization:", "Bearer " + token);
},
type: 'GET',
dataType: 'json',
contentType: 'application/json',
success: function (response) {
console.log(response);
},
error: function(error){
console.log(error)
}
});
-