Realm.io mongo google login

I’m trying to integrate google sign in with realm.io.
What I’m doing is:

  1. Scaffold new Ionic application.
  2. Create new credentials inside google developer console (client ID).
  3. Install @codetrix-studio/capacitor-google-auth complete the setup part for setting up client Id where its needed. This will retrieve google user object. For web, you want to initialize the GoogleAuth. For android, you will have to take additional setup with sha key.
  4. Install realm-web and inside main.ts initialize realm app using new Realm.App({ id: appId }).
  5. Setup code and run it.

This is my end code:

const signInWithGoogle = async () => {
  const response = await GoogleAuth.signIn();
  const { idToken } = response.authentication;

  const credentials = Realm.Credentials.google({ idToken });

 
  realm.logIn(credentials)
    .then((user) => {
      console.log(`Logged in with id: ${user.id}`);
    });
};

For now, this doesn’t work regarding realm.io side as I’m getting HTTP 401 response from realm.io.
I do understand that this is not ionic related issue.

  1. Has anyone integrated realm.io mongo google login flow?
  2. If yes, how did you manage to accomplish the required flow to work?
  3. Maybe there is other options like using firebase authentication with realm.io data storage?

Any help would be appreciated. :pray:

I’ve never seen realm being used in a web platform but rather in native projects (Swift and Kotlin/Java). Stick with firebase.

@mikrochipkid you can use realm for hosted mongoDB support