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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

I am getting error when trying to signin with next-auth #7466

Closed
dayemsiddiqui opened this issue May 6, 2023 · 5 comments
Closed

I am getting error when trying to signin with next-auth #7466

dayemsiddiqui opened this issue May 6, 2023 · 5 comments
Labels
question Ask how to do something or how something works

Comments

@dayemsiddiqui
Copy link

Question 馃挰

Hi I have the following code:

import NextAuth, {NextAuthOptions} from 'next-auth'
import GoogleProvider from 'next-auth/providers/google'

export const authOptions: NextAuthOptions = {
    providers: [
        GoogleProvider({
            clientId: process.env.GOOGLE_CLIENT_ID!,
            clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
            authorization: {
                params: {
                    prompt: "consent",
                    access_type: "offline",
                    response_type: "code"
                }
            }
        })
        ],
    secret: process.env.NEXTAUTH_SECRET!,
};

const handler =  NextAuth(authOptions)
export  {
    handler as GET,
    handler as POST,
}

And my env as follows:

GOOGLE_CLIENT_ID=<secret>
GOOGLE_CLIENT_SECRET=<secret>
NEXTAUTH_SECRET=<secret>
NEXTAUTH_URL=http://localhost:3000

And I am getting the following error whenever I try to signin:

[next-auth][error][SIGNIN_OAUTH_ERROR] 
https://next-auth.js.org/errors#signin_oauth_error crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported {
  error: {
    message: 'crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported',
    stack: 'Error: crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported\n' +
      '    at rng (/Users/dayemsiddiqui/dev/equity-oracle/.next/server/app/chunks/ssr/node_modules_b2bd82._.js:219530:19)\n' +
      '    at v4 (/Users/dayemsiddiqui/dev/equity-oracle/.next/server/app/chunks/ssr/node_modules_b2bd82._.js:219549:223)\n' +
      '    at Object.encode (/Users/dayemsiddiqui/dev/equity-oracle/.next/server/app/chunks/ssr/node_modules_b2bd82._.js:216199:76)\n' +
      '    at async signCookie (/Users/dayemsiddiqui/dev/equity-oracle/.next/server/app/chunks/ssr/node_modules_b2bd82._.js:217353:16)\n' +
      '    at async Object.create (/Users/dayemsiddiqui/dev/equity-oracle/.next/server/app/chunks/ssr/node_modules_b2bd82._.js:217410:22)\n' +
      '    at async getAuthorizationUrl (/Users/dayemsiddiqui/dev/equity-oracle/.next/server/app/chunks/ssr/node_modules_b2bd82._.js:217656:5)\n' +
      '    at async Object.signin (/Users/dayemsiddiqui/dev/equity-oracle/.next/server/app/chunks/ssr/node_modules_b2bd82._.js:217694:30)\n' +
      '    at async AuthHandler (/Users/dayemsiddiqui/dev/equity-oracle/.next/server/app/chunks/ssr/node_modules_b2bd82._.js:218842:36)\n' +
      '    at async NextAuthRouteHandler (/Users/dayemsiddiqui/dev/equity-oracle/.next/server/app/chunks/ssr/node_modules_b2bd82._.js:218992:30)\n' +
      '    at async NextAuth._args$ (/Users/dayemsiddiqui/dev/equity-oracle/.next/server/app/chunks/ssr/node_modules_b2bd82._.js:219026:24)\n' +
      '    at async /Users/dayemsiddiqui/dev/equity-oracle/.next/server/app/chunks/ssr/node_modules_b2bd82._.js:207749:37',
    name: 'Error'
  },
  providerId: 'google',
  message: 'crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported'
}
warning - [parse]
  ... [2 paths] are hidden, run with --show-all to show them
event - 3 requests (GET /api/auth/error, ...) 2405ms

Node version: 18

How to reproduce 鈽曪笍

Run the code above and you should see the error.

Node version: 18
OS: MacOS

Contributing 馃檶馃徑

Yes, I am willing to help answer this question in a PR

@dayemsiddiqui dayemsiddiqui added the question Ask how to do something or how something works label May 6, 2023
@dayemsiddiqui
Copy link
Author

I found the solution though it is not a problem with next-auth. I am posting this for future reference so it can help other folks.

The problem was that I was running the build using turbo, I solved it by not using turbo as my build tool

@godfrednanaowusu
Copy link

Why is this closed, i dont understand, it seems its been closed too quickly, this is a very serious issue.

Yes it happens when yarn dev --turbo is used on nextjs, but the issue is clearly pointing to modules in next-auth, specifically

node_modules/next-auth/node_modules/uuid/dist/esm-browser/v4.js:6:51

please take time to check this out before quickly closing it as completed.

its an issue with UUID, take a look here

uuidjs/uuid#708

@godfrednanaowusu
Copy link

can this issue be re-opened please, it seems the uuid version needs an update

@godfrednanaowusu
Copy link

it doesn't look like this serious issue is not being attended to, its been 2 weeks now, the issue reporter mentioned he or she could help, but this is still closed and not being worked on, can we get an update on this please.

@colemilne54
Copy link

it doesn't look like this serious issue is not being attended to, its been 2 weeks now, the issue reporter mentioned he or she could help, but this is still closed and not being worked on, can we get an update on this please.

Based on the comment by @dayemsiddiqui and what I also had to do to solve the same issue is that using turbo pack in your dev environment is likely causing this error. Navigate to your package.json file in your Next.js project and look at your scripts, if your dev script looks like this:

"scripts": { 
    "dev": "next dev --turbo",
}

change it to

"scripts": { 
    "dev": "next dev",
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Ask how to do something or how something works
Projects
None yet
Development

No branches or pull requests

4 participants