How to use the ember-simple-auth/authenticators/torii.extend function in ember-simple-auth

To help you get started, we’ve selected a few ember-simple-auth examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ptgamr / ember-kinto / tests / dummy / app / authenticators / torii.js View on Github external
import Ember from 'ember';
import ToriiAuthenticator from 'ember-simple-auth/authenticators/torii';

const { inject: { service } } = Ember;

export default ToriiAuthenticator.extend({
  torii: service(),
  ajax: service(),

  authenticate() {
    const ajax = this.get('ajax');
    return this._super(...arguments).then(data => {
      return ajax.request('http://localhost:8888/v1/github/token', {
        type: 'POST',
        dataType: 'json',
        data: {
          authorization_code: data.authorizationCode
        }
      }).then(({access_token}) => {
        return ajax.request('http://localhost:8888/v1/buckets/default', {
          type: 'GET',
          headers: {
github cardstack / cardstack / packages / authentication / addon / torii-authenticator.js View on Github external
import Ember from 'ember';
import ToriiAuthenticator from 'ember-simple-auth/authenticators/torii';
import fetch from 'fetch';

export default ToriiAuthenticator.extend({
  torii: Ember.inject.service(),

  authenticate() {
    let config = Ember.getOwner(this).resolveRegistration('config:environment');
    let tokenExchangeUri = config.cardstack.tokenURL;
    return this._super(...arguments).then((data) => {
      return fetch(tokenExchangeUri, {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json',
        },
        body: JSON.stringify({
          authorizationCode: data.authorizationCode
        })
      }).then(response => response.json()).then(response => {
        return {