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

Expired tokens don't refresh before a 401 error in @realm/react #5229

Closed
greenafrican opened this issue Jan 9, 2023 · 1 comment
Closed
Labels
O-Community T-Bug Waiting-For-Reporter Waiting for more information from the reporter before we can proceed

Comments

@greenafrican
Copy link

greenafrican commented Jan 9, 2023

How frequently does the bug occur?

Always

Description

We're using @realm/react in a React Native project and occasionally get 401 errors saying the user token has expired when making GraphQL requests. Subsequent requests appear to work.

Previously, I used the refreshToken process outlined here: https://www.mongodb.com/docs/realm/web/graphql-apollo-react/#refresh-access-tokens However, I don't see the refreshToken method available on the @realm/react useUser object. Instead it is a string.

Stacktrace & log output

[Error: Response not successful: Received status code 401]

Can you reproduce the bug?

Always

Reproduction Steps

Bring the app to the foreground after the user token has expired and the first request throws the 401 error, despite being wrapped inside of the Realm provider with an authenticated user logged in.

Version

@realm/react@0.4.1

What services are you using?

Atlas Device Sync

Are you using encryption?

No

Platform OS and version(s)

iOS 16.1.2 (20B110)

Build environment

Which debugger for React Native: ..

Cocoapods version

RealmJS (11.2.0)

@takameyer
Copy link
Contributor

@greenafrican the method refreshAccessToken is only implemented in realm-web. You can, however, use the method refreshCustomData, to update the access token. See react native documentation for details.

@sync-by-unito sync-by-unito bot added the Waiting-For-Reporter Waiting for more information from the reporter before we can proceed label Jan 9, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
O-Community T-Bug Waiting-For-Reporter Waiting for more information from the reporter before we can proceed
Projects
None yet
Development

No branches or pull requests

2 participants