gapi.auth2.getAuthInstance().isSignedIn.get() is always false when Chrome Browser has multiple accounts
Asked Answered
H

1

5

I copied the example given in Google Calendar API Quickstart and replaced it with the appropriate info. Every time I refresh the page, I'm asked to authorize before api data is fetched.

I'm using Chrome and I currently have multiple accounts / users. I noticed if I open an Incognito Window and sign in with one set of credentials then when I refresh the page I'm not asked to authorize.

Note, once I authenticate I receive calendar information so I don't believe it's an issue with client_id, api_key, scope, etc.

Looking at the example code, I'm guessing the getAuthInstance() is getting confused because of multiple accounts / users. Does anyone have any idea? Thanks!

Hemihydrate answered 29/3, 2018 at 19:39 Comment(1)
In my case, disabling adblockers and tracker blockers (Ghostery) both in my app and Gmail helped. Also, make sure you removed cached files, Local Storage & Session Storage records and cookies.Cilice
H
1

This was happening when running on localhost. This issue stopped happening after deploying the webpage to a hosted server.

Hemihydrate answered 2/4, 2018 at 22:37 Comment(1)
Thank you for this note, it helped me a lot. I've checked the documentation and this problem/restriction is didn't mentioned. Also I was able to add localhost as app url in my google console and there were no any warnings. I'm really dissaponted that such big and powerfull company as Google cannot provide a solid documentation for their API's.Betweenwhiles

© 2022 - 2024 — McMap. All rights reserved.