Google Sign In API: isSignedIn.get() returning inconsistent values

…衆ロ難τιáo~ 提交于 2019-12-01 17:22:18

Maybe I missed it in the documentation somewhere (if I did, it'd be nice if someone could point it out to me), but it looks like you can use Promises to make sure the GoogleAuth instance is ready. Here's what I did to get a consistent result:

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

  gapi.auth2.init({

    client_id: 'my_client_info.apps.googleusercontent.com',

  }).then(function(){

    auth2 = gapi.auth2.getAuthInstance();
    console.log(auth2.isSignedIn.get()); //now this always returns correctly        

  });
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!