Tuesday, 18 December 2018

Google Sign in doesn't work only for web mobile

My site is implementing Google Sign in with the code bellow and it's working pretty well.

When I try to do it in the mobile version all the flow works right, but I get not the answer of sign in. I guess it's because mobile version doesn't show a popup but new tab (Facebook have the same behavior as well...)

How should I procced to get it work in mobile version too?

gapi.load('auth2', function() {});

$(function() {
  $("#btn-google-login").on('click', function() {

    var proccedLogin = function(resp) {
      // my continue code...
    }

    // Retrieve the singleton for the GoogleAuth library and set up the client.
    auth2 = gapi.auth2.init({
      client_id: $('meta[name="google-signin-client_id"]').attr('content'),
      cookiepolicy: 'single_host_origin',
      prompt: 'consent',
      immediate: false
    }, function() {});

    auth2.signIn()
      .then(proccedLogin)
      .catch(function(error) {
        alert(JSON.stringify(error, undefined, 2))
      })

  }) // btn google click
})

Ps.: Error I get is 'popup_closed_by_user', but I didn't closed the tab by my own

Edit

Now I'm getting the 'popup_blocked_by_browser'. I followed some changes described in the link below but it just returning always the same error...

detect error: "popup_blocked_by_browser" for google auth2 in javascript



from Google Sign in doesn't work only for web mobile

No comments:

Post a Comment