Skip to content

Instantly share code, notes, and snippets.

@duizendnegen
Created April 8, 2017 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save duizendnegen/08cb84c42634f3153b63151905c7a26f to your computer and use it in GitHub Desktop.
Save duizendnegen/08cb84c42634f3153b63151905c7a26f to your computer and use it in GitHub Desktop.
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;
}
})
});
import OAuth2Bearer from 'ember-simple-auth/authorizers/oauth2-bearer';
export default OAuth2Bearer.extend();
module.exports = function(environment) {
// ...
ENV.torii = {
providers: {
'google-oauth2-bearer': {
apiKey: "YOUR-GOOGLE-OAUTH2-API-KEY",
redirectUri: "http://localhost:4200/oauth2callback"
}
}
};
// ...
});
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