GithubHelp home page GithubHelp logo

Comments (18)

MacWatrous avatar MacWatrous commented on May 24, 2024 3

Ugh I just figured it out.. My AUTH_GITHUB_SECRET had a space in front of it. Everything is working for me now!

from ai-chatbot.

balazsorban44 avatar balazsorban44 commented on May 24, 2024 1

Hmm. Maybe take a look at #80

After the applied changes there, not only login works when deployed: https://ai-chatbot.vercel.sh/ but it also supports OAuth login on preview deployments, eg: https://ai-chatbot-1qzzt58mx.vercel.sh/

So this is definitely a configuration issue, or an outdated version of next-auth that you are using.

from ai-chatbot.

cachho avatar cachho commented on May 24, 2024

I found #28 and changed the callback url to https://nextjs-chat-DOMAIN.vercel.app/api/auth/callback/github but still get the issue.

from ai-chatbot.

balazsorban44 avatar balazsorban44 commented on May 24, 2024

could you add a reproduction? the deployed example mentioned here #28 (comment) works.

from ai-chatbot.

cachho avatar cachho commented on May 24, 2024

could you add a reproduction? the deployed example mentioned here #28 (comment) works.

sure, I made it public but what I described as step 2 is the only thing that I actually changed in the code base: https://github.com/cachho/nextjs-chat

Edit: screenshot from github oauth:
Screenshot 2023-06-23 001230

from ai-chatbot.

cresencio avatar cresencio commented on May 24, 2024

Had the same issue and resolved following the suggestion from @balazsorban44, however my lock file references 0.0.0-manual.223c6467 and the Vercel server logs were failing to deploy. I checked the logs and one of the messages suggested running pnpm install --no-frozen-lockfile. I did that locally and then pushed to main and the build was successful. The Github login worked too. Ah, posted too soon. It's not exactly working because after authorizing the app I get redirected back but the login link does not change to my profile. I'll investigate tomorrow or over the weekend.

Before doing that, I also added the NEXTAUTH_SECRET generated from https://generate-secret.vercel.app/32

from ai-chatbot.

balazsorban44 avatar balazsorban44 commented on May 24, 2024

@cacho can you run pnpm up @auth/nextjs in your project? Your lockfile suggests you forgot to follow #28 (comment)

You can see the available versions at https://www.npmjs.com/package/@auth/nextjs?activeTab=versions As of writing, the latest experimental version is 0.0.0-manual.179c08d4 but you are on an 11 days old version.

@cresencio will need a reproduction.

from ai-chatbot.

cachho avatar cachho commented on May 24, 2024

@cacho can you run pnpm up @auth/nextjs in your project? Your lockfile suggests you forgot to follow #28 (comment)

Still the same stuff I've seen before. After a while the github authorize page opens, I authorize and then I get back to the sign in page (https://nextjs-chat-7wnb.vercel.app/api/auth/signin). Hitting the button again just reloads the page, and after hitting it for a dozen times I either get github's "reauthorization required" or "try signing in with a different account".

image

My repo has been updated.

edit: I found this in the logs

�[31m[auth][error][OAuthCallbackError]�[0m: OAuth Provider returned an error. Read more at https://errors.authjs.dev#oauthcallbackerror
    at handleOAuth (/var/task/.next/server/chunks/541.js:9423:15)
    at async callback_callback (/var/task/.next/server/chunks/541.js:9588:41)
    at async AuthInternal (/var/task/.next/server/chunks/541.js:10413:38)
    at async Auth (/var/task/.next/server/chunks/541.js:10664:30)
    at async /var/task/.next/server/chunks/550.js:1087:37

from ai-chatbot.

cresencio avatar cresencio commented on May 24, 2024

@balazsorban44 - the issue seems to have gone away! All I did was clear my cache 🤷‍♂️ But thanks anyway!

from ai-chatbot.

balazsorban44 avatar balazsorban44 commented on May 24, 2024

FYI: I've added some improvements in this PR #80 which is waiting for approval/merge.

from ai-chatbot.

balazsorban44 avatar balazsorban44 commented on May 24, 2024

@cachho I noticed that your description's 5th step says:

Add https://nextjs-chat-DOMAIN.vercel.app/ as my Homepage URL and Authorization callback URL for the Github oauth app.

This is wrong. The callback URL needs to be: https://nextjs-chat-DOMAIN.vercel.app/api/auth/callback/github as documented at https://authjs.dev/reference/core/providers_github#callback-url

That might be the issue!

from ai-chatbot.

cachho avatar cachho commented on May 24, 2024

@cachho I noticed that your description's 5th step says:

Add https://nextjs-chat-DOMAIN.vercel.app/ as my Homepage URL and Authorization callback URL for the Github oauth app.

This is wrong. The callback URL needs to be: https://nextjs-chat-DOMAIN.vercel.app/api/auth/callback/github as documented at https://authjs.dev/reference/core/providers_github#callback-url

That might be the issue!

sorry, I did not describe that right (I will correct my original post). I already made that change, please take a look at the screenshot I posted: #78 (comment)

And thanks for the help!

from ai-chatbot.

MacWatrous avatar MacWatrous commented on May 24, 2024

I'm also having no luck and I've deployed the latest version of this repo.

My error is

�[31m[auth][error][CallbackRouteError]�[0m: Read more at https://errors.authjs.dev#callbackrouteerror
�[31m[auth][cause]�[0m: OperationProcessingError: "response" body "access_token" property must be a non-empty string
    at processGenericAccessTokenResponse (/var/task/.next/server/chunks/57.js:8396:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async processAuthorizationCodeOAuth2Response (/var/task/.next/server/chunks/57.js:8556:20)
    at async handleOAuth (/var/task/.next/server/chunks/57.js:9388:18)
    at async callback_callback (/var/task/.next/server/chunks/57.js:9522:41)
    at async AuthInternal (/var/task/.next/server/chunks/57.js:10347:38)
    at async Auth (/var/task/.next/server/chunks/57.js:10598:30)
    at async /var/task/.next/server/chunks/550.js:1087:37
�[31m[auth][details]�[0m: {
  "provider": "github"
}

package.json and pnpm-lock.yaml both have version 0.0.0-manual.83c4ebd1 for next-auth

My Github OAuth app looks like:
image
(full expanded callback URL below)
image

from ai-chatbot.

balazsorban44 avatar balazsorban44 commented on May 24, 2024

@MacWatrous can you add a full reproduction, so I can take a look? As shown above, we have a deployed version now, working as expected, so there's likely something missing/misconfigured, I believe.

from ai-chatbot.

sametcodes avatar sametcodes commented on May 24, 2024

It solved the issue adding the vercel domain URL of the deployment as NEXTAUTH_URL on environment variables. It says NEXTAUTH_URL is required only for development purposes, but I guess something is missing on the code with that variable.

from ai-chatbot.

swyxio avatar swyxio commented on May 24, 2024

i think the issues are quite confusing. since a lot of them reference NEXTAUTH_URL, but now there is nothing in the template that is NEXTAUTH_URL

from ai-chatbot.

balazsorban44 avatar balazsorban44 commented on May 24, 2024

NEXTAUTH_URL does not need to be set on Vercel and hasn't been required for a while. See https://next-auth.js.org/deployment#vercel

NEXTAUTH_URL is required only for development purposes

@sametcodes This does not sound correct, it's not needed locally either. Can you point me to where this is stated so we can update this?

Recently merged some more instructions (#85), please see https://github.com/vercel-labs/ai-chatbot/blob/9c25c3f4b25278962e2a48e6e0c31e2b40ea86d7/.env.example#L5-L13 and read #89 (comment) for more details, and a working example deployed on Vercel (even supporting preview deployments).

from ai-chatbot.

imanirak avatar imanirak commented on May 24, 2024

Had this same issue, realized the wrong key was copied to the variable. So I had to update them and redeploy the website for changes to take effect.

from ai-chatbot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.