facebook - currentUser fetched in Authentication with Torii? -
trying change torii authenticator return account id response, it's available in session fetching account.
in trying adapt example torii authenticator, have starting point (obviously wrong, hitting on js knowledge limits):
import ember 'ember'; import torii 'simple-auth-torii/authenticators/torii'; import configuration 'simple-auth-oauth2/configuration'; export default torii.extend({ authenticate: function(credentials) { return this._super(provider).then((authresponse) => { return new ember.rsvp.promise(function(resolve, reject) { ember.$.ajax({ url: configuration.servertokenendpoint, type: 'post', data: { 'auth_code': authresponse.authorizationcode } }).then(function(response) { ember.run(function() { // properties promise resolves // available through session resolve({ access_token: response.access_token, account_id: response.account_id }); }); }, function(xhr, status, error) { ember.run(function() { reject(xhr.responsetext); }); }); }); }); } });
ember doesn't complain errors, of course facebook's auth dialog doesn't pop. lost @ point, pointers appreciated.
update
this provider code, working before changing authenticator try , return account_id well:
import ember 'ember'; import facebookoauth2 'torii/providers/facebook-oauth2'; let { resolve } = ember.rsvp; export default facebookoauth2.extend({ fetch(data) { return resolve(data); }, close() { return resolve(); } });
this previous, working authenticator:
import ember 'ember'; import torii 'simple-auth-torii/authenticators/torii'; import configuration 'simple-auth-oauth2/configuration'; export default torii.extend({ authenticate(provider) { return this._super(provider).then((authresponse) => { return ember.$.post(configuration.servertokenendpoint, { 'auth_code': authresponse.authorizationcode }).then(function(response) { return { 'access_token': response['access_token'], provider }; }); }); } });
Comments
Post a Comment