You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to run successive requests with one octokit instance and on the second request I'm getting this error:
RequestError [HttpError]: The code passed is incorrect or expired. (bad_verification_code, https://docs.github.com/apps/managing-oauth-apps/troubleshooting-oauth-app-access-token-request-errors/#bad-verification-code)
I'm using Next.js, passing the code from the frontend to an API route. Here's the code of the API route:
importtype{NextApiRequest,NextApiResponse}from"next";import{createOAuthUserAuth}from"@octokit/auth-oauth-user";import{Octokit}from"@octokit/rest";exportdefaultasyncfunctionhandler(req: NextApiRequest,res: NextApiResponse){const{ code }=req.body;// Logs the expected codeconsole.log("code",code);constoctokit=newOctokit({authStrategy: createOAuthUserAuth,auth: {clientId: process.env.NEXT_PUBLIC_CLIENT_ID,clientSecret: process.env.CLIENT_SECRET,
code,},});// First request// Copied over from the documentation, at https://github.com/octokit/auth-oauth-user.js#usage-with-octokitconst{data: { login },}=awaitoctokit.rest.users.getAuthenticated();// Logs my GitHub username, as expectedconsole.log("Hello, %s!",login);// Second request// Throws an errorawaitoctokit.rest.git.getRef({owner: "sine-fdn",repo: "tandem",ref: "heads/main",});res.status(200).json({data: `${req.body}`});}
I am new to octokit, so I am sorry if I'm missing something that should be clear.
Thank you very much for your work and for your attention!
The text was updated successfully, but these errors were encountered:
I also ran into this problem based on the instructions found here https://github.com/octokit/auth-oauth-user.js/#usage-with-octokit this is honestly one of the most headache-inducing documentation scenarios I've encountered. there's so many ways to use octokit that none of the documentation is consistent and the internals are super obfuscated with verbose typescript
Hello everyone!
I am trying to run successive requests with one octokit instance and on the second request I'm getting this error:
I'm using Next.js, passing the code from the frontend to an API route. Here's the code of the API route:
I am new to octokit, so I am sorry if I'm missing something that should be clear.
Thank you very much for your work and for your attention!
The text was updated successfully, but these errors were encountered: