Is it possible to connect to MongoDB Realm graphql api using the JWT token returned from Firebase

I am authenticating the user using the Firebase phone authentication method and I get a ID token returned using the below code -

String firebaseIdToken = await FirebaseAuth.instance.currentUser.getIdToken();
print("Token - "+ firebaseIdToken);

Here is my short of my return token data - eyJhbGciOiJSUzI1NiIsImtpZCI6IjFkZTgwNjdhODI5OGE0ZTMzNDRiNGRiZGVkMjVmMmZiNGY0MGYzY2UiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL3NlY3VyZ

I want to use MongoDB Realm graphql api to connect to my backend MongoDB collection. Since MongoDB does not have an official Graphql package for Flutter, I will be using graphql_flutter package.

How do I use the above token to connect to my MongoDB Realm graphql api using their Custom JWT authentication method and the graphql_flutter package? Please advise!

Hey Sumesh - the JWT Auth Provider should work with Firebase Auth. You can pass in the access token into the package after getting it from Realm like described in this docs section

1 Like