Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graphql throwing invalid session #3983

Closed
abhishekmatta999 opened this issue Sep 27, 2021 · 4 comments
Closed

Graphql throwing invalid session #3983

abhishekmatta999 opened this issue Sep 27, 2021 · 4 comments

Comments

@abhishekmatta999
Copy link

abhishekmatta999 commented Sep 27, 2021

How frequently does the bug occur?

Sometimes

Description

I’m using realm-graphql in my electron app. Now I’m facing an error while I’m passing authentication token in the header of graphql request.
This is the error:

Error: Network error: invalid session: failed to find refresh token at new ApolloError.

Here's my code:

async function getValidAccessToken () { const app = await getRealmApp() // Guarantee that there's a logged in user with a valid access token if (!app.currentUser) { // If no user is logged in, log in an anonymous user. The logged in user will have a valid // access token. const token = 'xyz....' if (token) { const credentials = Realm.Credentials.jwt(token); await app.logIn(credentials); } } else { // An already logged in user's access token might be stale. To guarantee that the token is // valid, we refresh the user's custom data which also refreshes their access token. await app.currentUser.refreshCustomData() } return app.currentUser.accessToken }

Stacktrace & log output

No response

Can you reproduce the bug?

Yes, sometimes

Reproduction Steps

No response

Version

10.4.0

What SDK flavour are you using?

MongoDB Realm (i.e. Sync, auth, functions)

Are you using encryption?

No, not using encryption

Platform OS and version(s)

Macos big sur Version: 11.5.2

Build environment

Which debugger for React Native: ..

@kneth
Copy link
Contributor

kneth commented Sep 27, 2021

Realm GraphQL only works with legacy Realm Cloud (pre v10). You will have to migrate to MongoDB Realm Cloud which supports GraphQL.

@abhishekmatta999
Copy link
Author

abhishekmatta999 commented Sep 27, 2021

@kneth
I'm already using the one(Mongodb version: 4.4.9).
As mentioned in the docs:
GraphQL requires MongoDB version 4.0 or greater.

@abhishekmatta999
Copy link
Author

abhishekmatta999 commented Sep 27, 2021

Realm GraphQL only works with legacy Realm Cloud (pre v10). You will have to migrate to MongoDB Realm Cloud which supports GraphQL.

And It was working till now with anonymous login. But as I mentioned above now I'm using custom JWT it starts showing me this error message
@kneth can you provide some info here.

@sync-by-unito sync-by-unito bot added the More-information-needed More information is needed to progress. The issue will close automatically in 2 weeks. label Sep 27, 2021
@no-response no-response bot removed the More-information-needed More information is needed to progress. The issue will close automatically in 2 weeks. label Sep 27, 2021
@kneth
Copy link
Contributor

kneth commented Nov 1, 2021

@sync-by-unito sync-by-unito bot closed this as completed Nov 1, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants