'[GAPI][Javascript]Signing-in parameter "login_hint" using gapi behaving differently on Safari and Chrome
I am seeing a small difference in behaviour when using this piece of code on Safari and Chrome.
window.gapi.load('auth2', () => {
window.gapi.auth2
.init({
client_id: getConfig('google').clientId,
ux_mode: 'popup',
scope: 'profile email openid',
login_hint: getLoggedInUserEmail(),
redirect_uri: `${window.location.origin}/${redirect_url}`,
})
.then(() => {
const GoogleAuth = window.gapi.auth2.getAuthInstance();
GoogleAuth.signIn().then(() => {
resolve(GoogleAuth.currentUser.get().getAuthResponse().id_token);
});
});
});
On Chrome : The authorization directly happens, i.e. the google popup opens, and closes after authorization without any user intervention. To be more specific - the url in the popup is (https://accounts.google.com/o/oauth2/auth?login_hint=getLoggedInUserEmail&openid.realm&scope=email+profile+openid&response_type=permission+id_token&redirect_uri=redirect_uri)
On Safari : The choose profile opens in the popup. This leads to user needing to select the account. To be more specific - the url in the popup is (https://accounts.google.com/o/oauth2/auth/oauthchooseaccount?login_hint=getLoggedInUserEmail&openid.realm&scope=email+profile+openid&response_type=permission+id_token&redirect_uri=redirect_uri)
Notice that, on chrome, sign-in flow redirects directly to /oauth2/auth and on safari, it redirects to /oauth2/auth/oauthchooseaccount.
I am already logged in to google in my browser using the email I am sending into login_hint while signing in using gapi.
My questions are -
- Why is there this discrepancy?
- Can Safari behave like Chrome?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
