GoogleWebComponents/google-signin

ux_mode not an option parameter for gapi.auth2.init

Opened this issue · 1 comments

I am trying to avoid a browser pop-up and use ux_mode='redirect' during init() or signIn() and it seems like I cannot use this as one of the option parameters to either of those methods. Has this been removed/modified?

index.html has this and loads appcomponent.html:
<script src="https://apis.google.com/js/platform.js" async defer></script>

appcomponent.html has this:

<google-signin id="signin"
               style="display: inline-block;"
               [clientId]="clientId"
               [scope]="scope"
               (googleSignInSuccess)="onGoogleSignIn()">
</google-signin>

<button style="float:right; height: 36px; display: inline-block;" class="btn btn-default" (click)="onGoogleSignOut();">Sign out</button>

And appcomponent.ts has the following:

onGoogleSignIn() {

   let googleAuth = gapi.auth2.getAuthInstance();
   this.user = googleAuth.currentUser.get();

   if (googleAuth.currentUser.get().isSignedIn()) {
     googleAuth.signIn().then((data) => {
       this.token = data.Zi.access_token;
     });
   }
   else
   {
     let authResp = this.user.getAuthResponse();
     this.token = authResp.access_token;
   }
 }

 onGoogleSignOut() {
   gapi.auth2.getAuthInstance().signOut().then(function () {
     console.log('User signed out.');
   });
 }

This works just fine. But I wanted to not have the pop-up and instead have the user be redirected to another page to select the google account to login with. So, I was trying to specify ux_mode in the signIn() parameters or add in a onLoad() function with init().

I get the pop-up using Polymer 1 with:

    <google-signin
          on-google-signin-success="googleSignInSuccess"
          client-id="333-foo.apps.googleusercontent.com"
          label-signin="Login with Google"
        ></google-signin>