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

error in openapi3filter.RequestError: refresh token is missing #2699

Open
Denis-NV opened this issue May 13, 2024 · 3 comments
Open

error in openapi3filter.RequestError: refresh token is missing #2699

Denis-NV opened this issue May 13, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@Denis-NV
Copy link

Describe the bug
When trying to use simple useSignInEmailPassword hook from the @nhost/react lib in order to authenticate with email and password, I can see 4 requests to https://[my-domain].auth.eu-west-2.nhost.run/v1/token in my browser's dev tools network tab, with first 3 of them sending refreshToken as a payload and get back response 200, yet the last one doesn't have a refreshToken in its payload and returns the following error:

"error": "error in openapi3filter.RequestError: request body has an error: doesn't match schema #/components/schemas/RefreshTokenRequest: Error at "/refreshToken": property "refreshToken" is missing"

Worth noting that a user gets authenticated fine.

To Reproduce
Steps to reproduce the behavior:

  1. Create Hasura Nhost project
  2. Create React App
  3. Install and configure @nhost/react client
  4. Try to authenticate with useSignInEmailPassword

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
image

Desktop (please complete the following information):

  • OS: Mac OS 14.2.1 (23C71)
  • Browser Chrome
  • Version 124.0.6367.119 (Official Build) (arm64)
@Denis-NV Denis-NV added the bug Something isn't working label May 13, 2024
@dbarrosop
Copy link
Contributor

Thanks for the report. That request should make no call to the /token endpoint though, so there must be something else going on. Would you mind providing a sample repository triggering the issue?

You can also take a look at our comprehensive react example which doesn't seem to trigger this issue:

code: https://github.com/nhost/nhost/tree/main/examples/react-apollo
website: https://react-apollo.example.nhost.io/sign-in

@Denis-NV
Copy link
Author

Thanks for your reply @dbarrosop. I tried to strip down my code to bare bones to isolate the issue and I think I found the cause of the problem. I was running my code locally in dev mode and I was already logged in as one of the users of my app. So, commenting out pretty much all the code from the root of my app and refreshing the browser page still produced the same error, as my user remained logged in. This made me thinking that it's got to be something to do with NhostClient trying to make those calls to https://[my-domain].auth.eu-west-2.nhost.run/v1/token endpoint under the hood. Fair enough, setting autoSignIn: false on the NhostClient constructor fixed the issue. Bare in mind that when I uncommented my log in / log out flow, I can still log in, refresh the page and my user remains logged in.

I wonder if the bug was introduced in the version of the "@nhost/react": "^3.4.2" that I'm using. In the example you provided (https://github.com/nhost/nhost/tree/main/examples/react-apollo) @nhost/react dependency gets imported locally from the mono-repo. So I don't really know what version it is.

P.S. The example you provided still uses the react-apollo dependency (https://github.com/nhost/react-apollo), which is deprecated on Feb 16, 2022 in favour of @nhost/apollo, however the new package usage is not documented and there are no examples of utilising it. I had to look into its source code to understand how to use it. It would be great if you could cover that gap. Otherwise thank for the work you're doing.

@dbarrosop
Copy link
Contributor

So I don't really know what version it is.

It uses the latest one as it is rebuilt on every release.

The example you provided still uses the react-apollo

The example I provided uses @nhost/react-apollo from the same repo.

however the new package usage is not documented and there are no examples of utilising it.

As mentioned above, the example above, the reference documentation and our quickstart are all using that library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants