I've been working with torii add-on to authenticate via linkedin.
I'm able to get the authorization code correctly, but having trouble to get the access token following this official tutorial:
If I follow this option, I get the following error:
XMLHttpRequest cannot load http://ift.tt/1W58hNt…&redirect_uri=REDIRECT_URI&client_id=CLIENT_ID&client_secret=CLIENT_SECRET. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'my-host.com:4200' is therefore not allowed access.
linkedInAccessToken: function(authenticationCode){
return new Ember.RSVP.Promise(function (resolve, reject) {
Ember.$.ajax({
type: "GET",
url: "http://ift.tt/1PHnRPw"+ authenticationCode +"&redirect_uri=REDIRECT_URI&client_id=CLIENT_ID&client_secret=CLIENT_SECRET",
success: function (response) {
console.log("ACCESS_TOKEN" + data.access_token);
resolve(data);
},
error: function (request, textStatus, error) {
console.log(error);
reject(error);
}
});
});
},
If I follow this other option, I get this error:
Refused to execute script from 'http://ift.tt/1W58hNt…llback&callback=jQuery1113038602466485463083_1445461451847&_=1445461451848' because its MIME type ('application/json') is not executable, and strict MIME type checking is enabled.
linkedInAccessToken: function(authenticationCode){
return new Ember.RSVP.Promise(function (resolve, reject) {
Ember.$.ajax({
type: "GET",
url: "http://ift.tt/1PHnRPw"+ authenticationCode +"&redirect_uri=REDIRECT_URI&client_id=CLIENT_ID&client_secret=CLIENT_SECRET&callback=jsonpcallback",
dataType: 'jsonp',
success: function (response) {
console.log("ACCESS_TOKEN" + data.access_token);
resolve(data);
},
error: function (request, textStatus, error) {
console.log(error);
reject(error);
}
});
});
},
jsonpcallback: function(data){
},
This last option returns the json on the network tab, but because of this problem i'm not being able to process it.
LinkedIn OAuth2 only returns json that's why i'm having the problem using 'jsonp'. On the other hand it's not cors either, that's why I'm having the problem on the first example.
Do you have any idea to help me solve this?
Thanks :)
Aucun commentaire:
Enregistrer un commentaire