I’m using the Realm SDK Google Auth RedirectURI. I’m getting the user data, accessToken, and refreshToken. What I’m not getting is the tokenId so that I can validate the session with my backend API.
I was using react-google-login with Mongo Anonymous login. I could use that tokenId to validate the session. I can’t seem to accomplish the same thing with Realm SDK redirect. I would have passed the AuthCode to Realm SDK, but that doesn’t work either based on this post.
My frontend is ReactJS. The backend is NodeJS. Here’s what I’m trying to accomplish.
Login Snippet:
const credentials = Realm.Credentials.google(redirectURI);
const user = await app.logIn(credentials);
Redirect Snippet:
handleAuthRedirect();
Fetch:
fetch(url, { method, headers, body: {...data, tokenId} });
API:
const client = new OAuth2Client(CLIENT_ID);
const ticket = await client.verifyIdToken({
idToken: token,
audience: CLIENT_ID,
});