Very new to ember and still wrapping my head around the framework. Using ember-cli 2.9.1.
I am trying to perform authentication using ember-simple-auth and its torii/google-oauth2 authenticator. At this point, everything works except the final step, the redirect after authentication succeeds. Seems like there are no tutorials or descriptions out there that describe this part in full.
I see that the authentication is performed successfully, I receive back an auth code and it gets stored in local storage. It persists across refreshes and all that. However, after the popup window dance happens, the redirect never occurs. I am still left sitting at the login page when I should be taken to the redirectUri that I registered with both my app and with Google.
Additionally, during the popup dance, two popup windows appear - the first being the one with content from Google, the second being the one that shows my redirectUrl in the address bar. However, both windows close quickly and the redirect does not happen on my main login page. There must be something I am not handling correctly in my main login page that is being provided in that second popup.
Here's the relevant code. Many thanks for your help!
config/environment.js:
// config/environment.js
var ENV = {
...
torii: {
providers: {
'google-oauth2': {
apiKey: '189573826905-p886jmjpam371fjoitktoec8hretkoo8.apps.googleusercontent.com',
redirectUri: 'https://localhost:4200/app/search',
}
}
},
...
};
app/components/google-signin-button.js
// app/components/google-signin-button.js
import Ember from 'ember';
export default Ember.Component.extend({
session: Ember.inject.service(),
didInsertElement() {
Ember.$.getScript('http://ift.tt/1bMh26W');
},
actions: {
authenticate_google() {
this.get('session').authenticate('authenticator:torii', 'google-oauth2');
},
invalidateSession() {
this.get('session').invalidate();
}
}
});
app/templates/components/google-signin-button.hbs
// app/templates/components/google-signin-button.hbs
<meta name="google-signin-client_id" content="755937126905-p886jmjpam371fjoitktoec8hretkoo8.apps.googleusercontent.com">
<div >
<h2 id="title">google oauth2 test</h2>
<div google-signin-button class="g-signin2"/>
</div>
<a >Logout</a>
Login
Aucun commentaire:
Enregistrer un commentaire