If I replace the asynch/await below with a then(gAuth) construct my call to Google Auth Init works. At present the init() call never returns and the browser hangs.
Am I misunderstanding the requirements of "await"?
async function gInit() {
// Check if already logged in with Google
try {
gAuth = await gapi.auth2.init({
client_id: providers.google.clientId
})
alert("sign in: " + gAuth.isSignedIn.get());
} catch (err) {
alert(err.message || err.text)
delete providers.google;
}
}
gapi.auth2.initreturning a promise that resolves with itself, thus creating an endless resolution loop. See github.com/google/google-api-javascript-client/issues/268initreturns aGoogleAuthobject. This object has athenmethod making it passis-promise. Thethenmethod resolves with theGoogleAuthobject itself so you can easily create an endless, recursive promise resolution loop. See the linked issue in my first commentthenmethod now resolves with the return value of its first,onInitargument. Not entirely clear what it does if that is omitted