[DOCS-13992] The Realm Web SDK documentation for Google OAuth doesn't work as provided Created: 18/Nov/20  Updated: 27/Oct/23  Resolved: 05/Jan/21

Status: Closed
Project: Documentation
Component/s: Realm
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Brian Leonard Assignee: Nicholas Larew
Resolution: Gone away Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:
Days since reply: 3 years, 5 weeks, 1 day ago
Epic Link: DOCSP-11710
Story Points: 3

 Description   

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.)



 Comments   
Comment by Nicholas Larew [ 05/Jan/21 ]

Will go away with updated OpenID snippets

Generated at Thu Feb 08 08:09:14 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.