Only allow google sign in with G Suite accounts?

て烟熏妆下的殇ゞ 提交于 2021-01-29 02:31:52

问题


I'm creating a custom web app and I'm using Google sign in to authenticate. I would like for the Choose an account screen, to only allow the user to chose a G Suite account to login to my web app. I'm aware of passing the param hostedDomain with a single domain, array or an asterisk. When I use the asterisk as the value, the Choose an account screen display correctly, only showing accounts that are G Suite. The issue is that I get an error after selecting a G Suite Account.

Error: 'Account domain does not match hosted_domain specified by gapi.auth2.init.'

I don't want to specify which domain/domains that needs to be allowed. I want to allow all G Suite domains.

Is there such a thing? I feel like something like this shouldn't require too much. Currently, I'm thinking of just using the method getHostedDomain() after a successful login if that return null or undefined then the current email/profile is not a G Suite account so logged them out before getting further into the web app.

Thanks in advance.

来源:https://stackoverflow.com/questions/60984997/only-allow-google-sign-in-with-g-suite-accounts

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