Uploaded image for project: 'Realm JavaScript SDK'
  1. Realm JavaScript SDK
  2. RJS-1935

error fetching info from OAuth2 provider

      How frequently does the bug occur?

      All the time

      Description

      We've recently upgraded from Stitch to Realm and authenticating to Google using the official docs.

      Here's the relevant code:

      useGoogleLogin({
          onSuccess: credentialResponse => {
            const token = credentialResponse.access_token;
            const credentials = Realm.Credentials.google({ token });
            app.logIn(credentials).then((user) => {
              console.log(`Logged in with id: ${user.id}`);
            });
          }, 
      onFailure: () => {
            // removed, as irrelevant
          },
      });
      

      Everything form Google is working fine; I receive the id_token, then I pass it along to Realm. That's when I get the error message.

      I've also tried passing along the auth code, but Realm just stalls with nothing returned. If I pass along the access_token, I get the same error as before.

      Stacktrace & log output

      Unable to find source-code formatter for language: shell. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      We get the following response after passing along the id_token from Google:
      
      Failed to load resource: the server responded with a status of 401 ()
      
      Our logs in MongoDB shows the following:
      
      error fetching info from OAuth2 provider
      Remote IP Address:
      [IP address removed for security reasons]
      

      Can you reproduce the bug?

      Yes, always

      Reproduction Steps

      Install Realm-web:
      npm i --save realm-web (version currently installed: 1.7.0)

      Import it:
      import * as Realm from "realm-web";

      Implement the code found here

      Retrieve the Google id_token (or auth code or access_token... doesn't seem to matter). Pass it along:

      const credentials = Realm.Credentials.google({ idToken });
      app.logIn(credentials).then((user) => {
      console.log(`Logged in with id: ${user.id}`);
      });
      

      Results in the the same error response every single time: error fetching info from OAuth2 provider

      If I switch on OpenID, it suddenly works, however, OpenID doesn't return the email, which is necessary for my use case, so that's not useful.

      Version

      1.7.0

      What SDK flavour are you using?

      Atlas App Services (auth, functions, etc.)

      Are you using encryption?

      Yes, using encryption

      Platform OS and version(s)

      Windows, Mac, Linux

      Build environment

      Which debugger for React Native: ..

      Cocoapods version

      No response

            Assignee:
            Unassigned Unassigned
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: