project_next_14_ai_prompt_sharing
project_next_14_ai_prompt_sharing copied to clipboard
next-auth error
I am about 1hr 35mins in the video and I am running into the following problem:
When pressing Sign-In on the Promptopia webpage, it says that I timed out, and displays the google sign-in button. Upon pressing the sign-in button, the same problem occurs.
The error appears in the console upon attempting sign-in:
[next-auth][error][SIGNIN_OAUTH_ERROR] https://next-auth.js.org/errors#signin_oauth_error outgoing request timed out after 3500ms { error: { message: 'outgoing request timed out after 3500ms', stack: 'RPError: outgoing request timed out after 3500ms\n' + ' at eval (webpack-internal:///(sc_server)/./node_modules/openid-client/lib/helpers/request.js:115:19)\n' + ' at async Issuer.discover (webpack-internal:///(sc_server)/./node_modules/openid-client/lib/issuer.js:135:30)\n' + ' at async openidClient (webpack-internal:///(sc_server)/./node_modules/next-auth/core/lib/oauth/client.js:12:18)\n' + ' at async getAuthorizationUrl (webpack-internal:///(sc_server)/./node_modules/next-auth/core/lib/oauth/authorization-url.js:88:20)\n' + ' at async Object.signin (webpack-internal:///(sc_server)/./node_modules/next-auth/core/routes/signin.js:21:30)\n' + ' at async AuthHandler (webpack-internal:///(sc_server)/./node_modules/next-auth/core/index.js:259:36)\n' + ' at async NextAuthRouteHandler (webpack-internal:///(sc_server)/./node_modules/next-auth/next/index.js:49:30)\n' + ' at async NextAuth._args$ (webpack-internal:///(sc_server)/./node_modules/next-auth/next/index.js:83:24)\n' + ' at async eval (webpack-internal:///(sc_server)/./node_modules/next/dist/server/future/route-modules/app-route/module.js:244:37)', name: 'RPError' }, providerId: 'google', message: 'outgoing request timed out after 3500ms' }
Things I have tried -
- Verified .env variables match variables in google cloud
- Checked firewall settings for incoming and outgoing connections
- Checked for DNS issues in resolve.conf
- I ran dig and ping on accounts.google.com without issue, correctly receiving response
- I checked for Time Sync issues
- I put in browser: https://accounts.google.com/o/oauth2/v2/auth?client_id=YOUR_CLIENT_ID&response_type=code&scope=openid%20email%20profile&redirect_uri=YOUR_REDIRECT_URI&state=STATE_STRING&prompt=consent to yield an authorization code
and then I ran: curl -d "code=AUTHORIZATION_CODE&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET&redirect_uri=YOUR_REDIRECT_URI&grant_type=authorization_code" -H "Content-Type: application/x-www-form-urlencoded" -X POST "https://oauth2.googleapis.com/token"
and I successfully yielded a JSON response, so it seems the issue is to do with my code, and not my google cloud project settings.
ALSO: I am running the next-js application in an Ubuntu virtual machine using Virtual Box. The settings for the VBox is so that the wifi adapter is bridged.
The project is on my github as a repository under the name "share-prompts" for those who would like to see the code.
If anyone can help out with figuring out why this timeout is occurring, help is appreciated.
` <button type="button" onClick={() => signIn('google')} className="black_btn" > SignIn
`
I suggest you to replace your code like this in "nav.jsx" like this and try it
onClick = {() => signIn('google')}
like this it will solve the error. good Luck.
@salmansheri Unfortunately, this did not change the results of anything. The same error occurs.
In cloud google console in redirect url add this url "http://localhost:3000/api/auth/callback/google" if running on local machine and also add this url "http://localhost:3000"
@YugBhanushali I already did that, this step is covered in his video.
I am also facing the same issue.
const response = await getProviders()
will get the provider without having to manually type signIn('google') or anything
you can use the signIn(provider.id)
to signIn
let me know if that still doesn't work
I have done that changes but still it gives the same error
I think this issue is specific to localhost. It worked for me when I used a VPN.
I try to expand the timeout
GoogleProvider({ clientId: process.env.GOOGLE_ID, clientSecret: process.env.GOOGLE_CLIENT_SECRET, httpOptions:{ timeout:50000 } })
then, get another error
https://next-auth.js.org/errors#signin_oauth_error read ECONNRESET {
error: {
message: 'read ECONNRESET',
stack: 'Error: read ECONNRESET\n' +
' at TLSWrap.onStreamRead (node:internal/stream_base_commons:217:20)\n' +
' at TLSWrap.callbackTrampoline (node:internal/async_hooks:130:17)',
name: 'Error'
},
providerId: 'google',
message: 'read ECONNRESET'
}