Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-13992

The Realm Web SDK documentation for Google OAuth doesn't work as provided

    • Type: Icon: Bug Bug
    • Resolution: Gone away
    • Priority: Icon: Major - P3 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

       

      Scope of changes

      Impact to Other Docs

      MVP (Work and Date)

      Resources (Scope or Design Docs, Invision, etc.)

            Assignee:
            nick.larew@mongodb.com Nicholas Larew
            Reporter:
            brian.leonard@mongodb.com Brian Leonard
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              3 years, 15 weeks, 2 days ago