-
Type: Bug
-
Resolution: Gone away
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Realm
-
Labels:None
Description
The Realm Web SDK documentation for Google OAuth doesn't work as provided. The documentation recommends using the official Google SDK. Following those steps provides Google user profile information, but that information doesn't contain the Authorization Code required by Realm, which is why we provide additional code on how do get the authorization code:
function getGoogleAuthCode() { return new Promise(() => { gapi.auth2.authorize({ client_id: "<Google Client ID>", // Scopes should match the metadata fields in the provider configuration scope: "<scopes>", response_type: "code", }, ({ code, error }) => { if(error) { reject(error) } resolve(code) }) }) }
However, calling that code fails with the error:
gapi.auth2.ExternallyVisibleError: gapi.auth2.authorize cannot be called after GoogleAuth has been initialized
I believe the limitation is that the guide you recommend doesn't contain the authorization code that Realm requires. If it does (and that would be great), then we need to document how to get it from the googleUser object returned.
If it is indeed not available in the googleUser object, we should probably instead direct our readers to the Google Sign-In JavaScript client reference.