question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

'500 Internal Server Error' with Bungie Provider

See original GitHub issue

Question 💬

I’m trying to get Next Auth working with Bungie. There is a provider included with Next Auth, but it doesn’t work out of the box. I have solved one problem with it, but am now stumped with a second.

Bungie requires a few unique things for their Oauth. One, you need to use https even locally. Two, you can’t use ‘localhost’. You need 127.0.0.1 or something configured in your hosts file. I have that setup – Next is running with SSL on 127.0.0.1. I have even configured the GitHub Provider and that continues to work perfectly.

The first thing I did is recreate the Provider as a file/import within my project so I could modify it. I needed to change that authorization line to the following as Bungie errors out if you send any scope.

authorization: {
         url: 'https://www.bungie.net/en/OAuth/Authorize?reauth=true',
         params: {
            scope: '',
         },
      },

Now I am getting the following error after approving the request on Bungie’s site. Again, the GitHub provider continues to work while Bungie is giving this error. I also got confirmation that I had authorized the app on my Bungie account the first time I completed this.

[next-auth][error][OAUTH_CALLBACK_ERROR]
https://next-auth.js.org/errors#oauth_callback_error expected 200 OK, got: 500 Internal Server Error {
  error: {
    message: 'expected 200 OK, got: 500 Internal Server Error',
    stack: 'OPError: expected 200 OK, got: 500 Internal Server Error\n' +
      '    at processResponse (F:\\websites\\projects\\destiny-watch\\node_modules\\openid-client\\lib\\helpers\\process_response.js:41:11)\n' +
      '    at Client.userinfo (F:\\websites\\projects\\destiny-watch\\node_modules\\openid-client\\lib\\client.js:1257:18)\n' +
      '    at processTicksAndRejections (node:internal/process/task_queues:96:5)\n' +
      '    at async oAuthCallback (F:\\websites\\projects\\destiny-watch\\node_modules\\next-auth\\core\\lib\\oauth\\callback.js:134:17)\n' +
      '    at async Object.callback (F:\\websites\\projects\\destiny-watch\\node_modules\\next-auth\\core\\routes\\callback.js:50:11)\n' +
      '    at async NextAuthHandler (F:\\websites\\projects\\destiny-watch\\node_modules\\next-auth\\core\\index.js:139:28)\n' +
      '    at async NextAuthNextHandler (F:\\websites\\projects\\destiny-watch\\node_modules\\next-auth\\next\\index.js:21:19)\n' +
      '    at async F:\\websites\\projects\\destiny-watch\\node_modules\\next-auth\\next\\index.js:57:32\n' +
      '    at async Object.apiResolver (F:\\websites\\projects\\destiny-watch\\node_modules\\next\\dist\\server\\api-utils\\node.js:185:9)\n' +
      '    at async DevServer.runApi (F:\\websites\\projects\\destiny-watch\\node_modules\\next\\dist\\server\\next-server.js:395:9)',
    name: 'OPError'
  },
  providerId: 'bungie2',
  message: 'expected 200 OK, got: 500 Internal Server Error'
}

How to reproduce ☕️

  1. Install Next, Next Auth
  2. Configure Next to use SSL and 127.0.0.1, including adding NEXTAUTH_URL=https://127.0.0.1:3000 to .env files. I followed the instructions at https://next-auth.js.org/providers/bungie and the linked page (https://medium.com/@anMagpie/secure-your-local-development-server-with-https-next-js-81ac6b8b3d68)
  3. Create my own provider for Bungie based off of the one that ships with Next. See https://github.com/royanger/destiny-item-watch/blob/86c0468da7d35c27523c9095d4a39775e8f3c652/libs/auth/bungie.js
  4. Configure Bungie App (see image) Image 1
  5. Run Next app and attempt to login via Bungie.

The follow is the output from the procees:

[next-auth][debug][CREATE_STATE] { state: 'tFS-qq68Dx7D-q58oq_FkSb82WBVp3IM9YcoJa0kIO4', maxAge: 900 }
[next-auth][debug][GET_AUTHORIZATION_URL] {
  url: 'https://www.bungie.net/en/OAuth/Authorize?reauth=true&client_id=40576&scope=&response_type=code&redirect_uri=https%3A%2F%2F127.0.0.1%3A3000%2Fapi%2Fauth%2Fcallback%2Fbungie2&state=tFS-qq68Dx7D-q58oq_FkSb82WBVp3IM9YcoJa0kIO4',
  cookies: [
    {
      name: '__Secure-next-auth.state',
      value: 'eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIn0..dSzcoBCsMiZT7XyU.uZtRDBS1F4r-mZpcuKxdwgXoxXwm9N3vrqb9CnDyqqtVZ1qMZjOZh_gVUrZlBfdtRDrCHIwsMm6o6OrZKicuL2oGlka5kiMOgKpEQ6ehGDyrTrPt1fKmTvk92J1JBE1vBN-2Z-6ufK6cjUvSVQQScfh2mJ_r0f_9_QXOkm57e5xwjSHdAu8.679kdC7wStAQpoy2Ow_eDg',
      options: [Object]
    }
  ]
}
[next-auth][error][OAUTH_CALLBACK_ERROR]
https://next-auth.js.org/errors#oauth_callback_error expected 200 OK, got: 500 Internal Server Error {
  error: {
    message: 'expected 200 OK, got: 500 Internal Server Error',
    stack: 'OPError: expected 200 OK, got: 500 Internal Server Error\n' +
      '    at processResponse (F:\\websites\\projects\\destiny-watch\\node_modules\\openid-client\\lib\\helpers\\process_response.js:41:11)\n' +
      '    at Client.userinfo (F:\\websites\\projects\\destiny-watch\\node_modules\\openid-client\\lib\\client.js:1257:18)\n' +
      '    at processTicksAndRejections (node:internal/process/task_queues:96:5)\n' +
      '    at async oAuthCallback (F:\\websites\\projects\\destiny-watch\\node_modules\\next-auth\\core\\lib\\oauth\\callback.js:134:17)\n' +
      '    at async Object.callback (F:\\websites\\projects\\destiny-watch\\node_modules\\next-auth\\core\\routes\\callback.js:50:11)\n' +
      '    at async NextAuthHandler (F:\\websites\\projects\\destiny-watch\\node_modules\\next-auth\\core\\index.js:139:28)\n' +
      '    at async NextAuthNextHandler (F:\\websites\\projects\\destiny-watch\\node_modules\\next-auth\\next\\index.js:21:19)\n' +
      '    at async F:\\websites\\projects\\destiny-watch\\node_modules\\next-auth\\next\\index.js:57:32\n' +
      '    at async Object.apiResolver (F:\\websites\\projects\\destiny-watch\\node_modules\\next\\dist\\server\\api-utils\\node.js:185:9)\n' +
      '    at async DevServer.runApi (F:\\websites\\projects\\destiny-watch\\node_modules\\next\\dist\\server\\next-server.js:395:9)',
    name: 'OPError'
  },
  providerId: 'bungie2',
  message: 'expected 200 OK, got: 500 Internal Server Error'
}

The repo is located at https://github.com/royanger/destiny-item-watch

Contributing 🙌🏽

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

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:16 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
royangercommented, Jul 31, 2022

Something I just recalled, and I’m not sure if you saw in the API docs as its barely mentioned, is that you need to be running https even locally for dev. You can’t auth with Bungie from http://localhost.

1reaction
royangercommented, Jul 27, 2022

I ended up getting Bungie working for Passport and Remix-auth. I didn’t revisit this yet, as I haven’t needed to (I’m building with Vite+React and Passport). That said, there is a separate URL to that you can use for OAuth tools like this to get the membership info -> https://www.bungie.net/Platform/User/GetMembershipsForCurrentUser/ As you can see you don’t need a membershipID or anything.

Read more comments on GitHub >

github_iconTop Results From Across the Web

500: internal server error CANT LOGIN! > Help - Bungie
For anyone having trouble with this check you steam name, if you have special characters in it sometimes that will block you from...
Read more >
500 Internal Server Error | Apigee Edge
Check the availability of the resource on the backend server. It might not be available temporarily/permanently or it might have been moved to...
Read more >
Community Tip - Fixing Error 500: Internal Server Error
An Error 500: Internal Server Error generally means the origin web server has encountered an unexpected condition and was unable to fulfill ...
Read more >
500 Internal Server Error - HTTP - MDN Web Docs - Mozilla
The HyperText Transfer Protocol (HTTP) 500 Internal Server Error server error response code indicates that the server encountered an ...
Read more >
Bungie.net: 500: Internal Server Error | Anyone else getting this?
Haven't seen any mentions on Bungie help twitter. Been running into this a lot today. 11/10 posts will get me this error with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found