realm-js: error exchanging access code with OAuth2 provider (Google login, nodejs SDK)
Goals
Logging into Realm via Google OAuth2
Expected Results
Successful processing of my submitted id_token from Google.
Actual Results
Login failed. Error message: {message: 'error exchanging access code with OAuth2 provider', code: 47}
Error message from MongoDB Realm logs.
Steps to Reproduce
Follow the guide from the Realm docs. (https://docs.mongodb.com/realm/authentication/google/)
Specifically I did the following:
- Create new credentials in Google developer console
- Enabled the auth provider on Realm.
- Created a client secret
googlethat has my client secret from Google console - Enabled all relevant callback URIS, authorized domains, etc. with Google and Realm
- Created a Google sign in button which gave me an
id_tokenwhich was successfully sent and processed by NodeJS.
When running the realmApp.logIn(credentials) function, this error message appeared.
Code Sample
Front-end sending tokens to back-end
Node back-end processing (fails on line 86 with error message above)
Version of Realm and Tooling
- Realm JS SDK Version:
10.0.0-beta.9 - Node or React Native: Node
- Client OS & Version: Ubuntu 18.04 LTS
- Which debugger for React Native: n/a
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 22 (5 by maintainers)
Feel free to moderate me if you like because I’m actually using the web sdk but I just got a solution today that worked for me that you can try with the nodjs sdk. Full disclosure I don’t use the nodejs sdk so I don’t know if it will help or if this is even an issue anymore. If I’m steering people in the wrong direction let me know. I’m just trying to help. Here is the link to the solution that works with the web sdk:
https://github.com/realm/realm-js/issues/5078
@vegar This is the right repo but it is a different library than the original poster - can you please open a separate issue to cover this since we believe we have fixed the OP’s issue for node.js and you could be experiencing a different issue. For instance, the issue @kneth mentioned on Google’s side is their breaking change with redirect_uri - which manifests itself as the same symptom (“error exchanging access code with OAuth2 provider”) - but the cause is separate
Am too facing this same error, when trying to implement Google login on Android.