Nekonyx / next-auth-steam

Steam authentication provider for next-auth
70 stars 18 forks source link

Multiple errors that I have encountered #2

Closed iBims1JFK closed 1 year ago

iBims1JFK commented 1 year ago

Hello, thank you for your effort, but I have encountered some errors and you might know how to fix them. Unfortunately, I did not make any for the examples work.

The first thing is about the .env file: As far as I can see only the STEAM_SECRET is used and NEXTAUTH_SECRET, NEXTAUTH_URL is not? So I would suggest to remove it from the example file or at least document it somewhere. Also STEAM_SECRET should be renamed to STEAM_API_KEY I think, because at the beginning it was very confusing.

Second: When I try to use the suggested import of import SteamProvider from 'next-auth-steam' I get this error Cannot find module 'next-auth-steam' or its corresponding type declarations. And I think that the import statement is not quiet correct because there is no default export and only the function export, so I think that the correct import statement should be import { Steam as SteamProvider } from 'next-auth-steam'.

Third: After working around this issues I get this error after logging in with steam: [next-auth][error][OAUTH_CALLBACK_ERROR] https://next-auth.js.org/errors#oauth_callback_error Invalid or replayed nonce { error: OAuthCallbackError: Invalid or replayed nonce at oAuthCallback (webpack-internal:///(sc_server)/./node_modules/next-auth/core/lib/oauth/callback.js:151:15) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Object.callback (webpack-internal:///(sc_server)/./node_modules/next-auth/core/routes/callback.js:18:83) at async AuthHandler (webpack-internal:///(sc_server)/./node_modules/next-auth/core/index.js:202:38) at async NextAuthRouteHandler (webpack-internal:///(sc_server)/./node_modules/next-auth/next/index.js:49:30) at async eval (webpack-internal:///(sc_server)/./node_modules/next/dist/server/future/route-modules/app-route/module.js:233:33) { code: undefined }, providerId: 'steam', message: 'Invalid or replayed nonce' }

Thank you for helping me out and I like to help with the implementation of this library but at the moment I do not have enough spare time :(

Nekonyx commented 1 year ago

Hey, thank you for your interest in my work.

1) This is just an example. It is not necessary to specify and use the environment variable STEAM_SECRET. You can specify the API key wherever and however you want, even directly in the provider settings. However, NEXTAUTH_SECRET/NEXTAUTH_URL, which you are referring to, still need to be specified because it is already a requirement of next-auth.

2) Could you please tell me more about your project? Are you using ES modules instead of CommonJS? Because import Steam from 'next-auth-steam' is the correct approach to using the library. We export Steam as the default export in src/index.ts.

3) I don't know anything about this error. A quick search on Google led me to this issue and comment on GitHub: https://github.com/dialupnoises/steam-login/issues/14#issuecomment-1307770788 According to it, having multiple Steam libraries can break each other's functionality (which is certainly strange). Perhaps you could upload a minimal example of your project in which this error occurs to the GitHub repository so that I can check and tell you if the error is related to my library and if we can do anything about it?

iBims1JFK commented 1 year ago

Thank you for your fast reply. I found out the functionality of the env variables by myself and I think the big mistake of the import statement was that I did not compile the library because I am not used to work with the source files. So the import statement is correct that you wrote. Regarding the actual problem: I was not even using the library in my own project, I just tried to execute the example with the app directory. So there are no other Steam dependencies. But it seems that not even the passport-steam example is working on my machine. At this point I am unsure if its a problem with the libraries or with my machine. I found this issue that maybe suggests that I have to change some settings https://github.com/liamcurry/passport-steam/issues/68 . Do you have any idea?

Nekonyx commented 1 year ago

If you are trying to use the example, try doing it this way:

  1. Make sure your Node.js version is >=18 (node -v).
  2. Clone this repository and change directory to examples/basic.
  3. Open package.json and replace file:../../ in this line with latest: https://github.com/Nekonyx/next-auth-steam/blob/0ca03076d7c4004d051a7f0d128d451f7d338e81/examples/basic/package.json#L12
  4. Install all dependencies using pnpm install.
  5. Create .env file and fill it out according to the example in .env.example.
  6. Start the local server using pnpm dev.
iBims1JFK commented 1 year ago

Thank you for these instructions but it really seemed to be a problem with my system. I found this comment https://github.com/liamcurry/passport-steam/issues/68#issuecomment-658367752 which suggested this command timedatectl set-ntp true which fixed the issue so far. I know that it has nothing to do with your code but maybe you could mention the problem and fix in a "known issues" section in the readme file. I think this could help other people when they having the same problem.