Workflow for Ember-simple-auth, Torii and Facebook Oauth2

后端 未结 3 2019
闹比i
闹比i 2020-12-13 07:45

After my previous question about ember-simple-auth and torii, I successfully authenticate my users with their Facebook accounts.

But currently, torii\'s provider fac

3条回答
  •  离开以前
    2020-12-13 08:25

    I used this:

    import Ember from 'ember';
    import Torii from 'ember-simple-auth/authenticators/torii';
    import ENV from "../config/environment";
    
    const { inject: { service } } = Ember;
    
    export default Torii.extend({
      torii: service(),
      ajax: service(),
    
      authenticate() {
        const ajax = this.get('ajax');
    
        return this._super(...arguments).then((data) => {
          return ajax.request(ENV.APP.API_HOST + "/oauth/token", {
            type:     'POST',
            dataType: 'json',
            data:     { 'grant_type': 'assertion', 'auth_code': data.authorizationCode, 'data': data }
          }).then((response) => {
            return {
              access_token: response.access_token,
              provider: data.provider,
              data: data
            };
          }).catch((error) => {
            console.log(error);
          });
        });
      }
    });
    

提交回复
热议问题