Hi, I have a web app that uses Realm and Realm.LogIn with email/password. This works and I receive the user object and access/refresh tokens. Now, when I call one of my own API endpoints, say api.mysite.com/getsomething, how do I authenticate the logged in user from my Node app middleware?
My Node app runs as a CloudFlare worker. I can pass it the access/refresh tokens in headers or even the body of every request to my own API. But, once my Node app receives the session/user tokens, how do I then instantiate and call Realm services with the user’s tokens?
My Client
var response = null;
this.user = await this.RealmApp.logIn(credentials).then(res => {
response = res;
}).catch(error => {
console.log("ControllerDatabase: LogIn error is - " + JSON.stringify(error));
});
My Node Server App
// How do I authenticate to Realm
var userSession = {
accessToken: "tokenPassedFromMyWebClient",
refreshToken: "tokenPassedFromMyWebClient"
};
// ... how to auth ... ?
// After auth, get some data from Realm
const col = this.TheAtlasDB.collection(collection);
if (col) return await col.findOne(query);
return null;
Thanks!