Created
April 8, 2017 14:04
-
-
Save duizendnegen/08cb84c42634f3153b63151905c7a26f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import AjaxService from 'ember-ajax/services/ajax'; | |
export default AjaxService.extend({ | |
session: Ember.inject.service('session'), | |
host: 'http://localhost:8080', | |
headers: Ember.computed('session', { | |
get() { | |
let headers = {}; | |
this.get('session').authorize('authorizer:application', (headerName, headerValue) => { | |
headers[headerName] = headerValue; | |
}); | |
return headers; | |
} | |
}) | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import OAuth2Bearer from 'ember-simple-auth/authorizers/oauth2-bearer'; | |
export default OAuth2Bearer.extend(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(environment) { | |
// ... | |
ENV.torii = { | |
providers: { | |
'google-oauth2-bearer': { | |
apiKey: "YOUR-GOOGLE-OAUTH2-API-KEY", | |
redirectUri: "http://localhost:4200/oauth2callback" | |
} | |
} | |
}; | |
// ... | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import Torii from 'ember-simple-auth/authenticators/torii'; | |
const { service } = Ember.inject; | |
export default Torii.extend({ | |
torii: service('torii'), | |
authenticate(options) { | |
return this._super(options).then(function (data) { | |
return { | |
provider: data.provider, | |
access_token: data.authorizationToken.access_token | |
}; | |
}); | |
}, | |
restore: function(data) { | |
return this._super(...arguments).then(() => { | |
return data; | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment