I am trying to create a custom OAuth Provider for Ember Simple Auth Torri wrapper for Yahoo OAuth 2.0. I used the built in providers for Facebook and Google without any problems,but since Yahoo OAuth package is not provided by default I am trying to follow the manual and create my own.
//app/torri-provider/yahoo-oauth2.js
export default Ember.Object.extend({
host: 'http://ift.tt/1HTHuyV',
// create a new authorization
open: function(options) {
return new Ember.RSVP.Promise(function(resolve, reject){
console.log("Hi");
var authurl="http://ift.tt/1INw4NT";
return $.ajax(authurl, "GET", {
// CORS
crossDomain: true,
xhrFields: {withCredentials: true}
}).then(function(json) {
// Massage this demo API endpoint to look like RESTAdapter expects.
return { things: [json] };
});
});
}
});
In my controller,I am calling it as -
'yahoo-share':function(){
var self=this;
this.get('session').authenticate('simple-auth-authenticator:torii',"yahoo-oauth2");
},
I am however unable to get part the CORS issue and receiving the following error on my console-
userhomeinvitemembers:1 XMLHttpRequest cannot load http://ift.tt/1INw4NT. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access.
I have tried adding the oauth2 endpoint to ember cli whitelist and content security policy whitelist but still getting the same error.
ENV.contentSecurityPolicy = {
'default-src': "'none'",
'script-src': "'self' http://localhost:4200/",
'font-src': "'self' http://localhost:4200/",
'connect-src': "'self' http://localhost:4200/ http://localhost:3000/ http://ift.tt/1HTHuyZ http://ift.tt/1INw4NT",
'img-src': "'self'",
'style-src': "'self'",
'media-src': "'self'"
},
ENV['simple-auth'] = {
crossOriginWhitelist: ['http://ift.tt/1INw4NT'],
authorizer: 'simple-auth-authorizer:oauth2-bearer',
authenticationRoute: 'index',
routeIfAlreadyAuthenticated:'userwelcome',
},
ENV['torii'] = {
providers: {
'facebook-oauth2': {
apiKey: '799728020115355'
},
'google-oauth2': {
apiKey:'299472944809-sddblocmketamp64sapk51qdrromkj0g.apps.googleusercontent.com',
scope: 'http://ift.tt/yb7fwm',
redirectUri:'http://localhost:4200/userhomeinvitemembers'
},
'yahoo-oauth2': {
apiKey:'dj0yJmk9UmpXWG1odlVlenRSJmQ9WVdrOVdFUkxRbVo2TkdVbWNHbzlNQS0tJnM9Y29uc3VtZXJzZWNyZXQmeD04Zg--',
}
}
};
Aucun commentaire:
Enregistrer un commentaire