[GH-ISSUE #4735] [bug]: Failed to obtain access token via MicrosoftSSO behind a proxy #1769

Open
opened 2026-03-16 21:40:37 +03:00 by kerem · 3 comments
Owner

Originally created by @MassBklf on GitHub (Feb 7, 2025).
Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/4735

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

When I try a login via Microsoft SSO, I get a 500 server error.

Browserlog:

statusCode | 500
message | "Internal server error"

Serverlog:

hoppscotch-aio       | Backend Server | [Nest] 37  - 02/07/2025, 10:06:39 AM   ERROR [ExceptionsHandler] Failed to obtain access token
hoppscotch-aio       | Backend Server | InternalOAuthError: Failed to obtain access token
hoppscotch-aio       | Backend Server |     at OAuth2Strategy._createOAuthError (/dist/backend/node_modules/.pnpm/passport-oauth2@1.8.0/node_modules/passport-oauth2/lib/strategy.js:423:17)
hoppscotch-aio       | Backend Server |     at /dist/backend/node_modules/.pnpm/passport-oauth2@1.8.0/node_modules/passport-oauth2/lib/strategy.js:177:45
hoppscotch-aio       | Backend Server |     at /dist/backend/node_modules/.pnpm/oauth@0.10.0/node_modules/oauth/lib/oauth2.js:196:18
hoppscotch-aio       | Backend Server |     at ClientRequest.<anonymous> (/dist/backend/node_modules/.pnpm/oauth@0.10.0/node_modules/oauth/lib/oauth2.js:166:7)
hoppscotch-aio       | Backend Server |     at ClientRequest.emit (node:events:519:28)
hoppscotch-aio       | Backend Server |     at TLSSocket.socketErrorListener (node:_http_client:500:9)
hoppscotch-aio       | Backend Server |     at TLSSocket.emit (node:events:519:28)
hoppscotch-aio       | Backend Server |     at emitErrorNT (node:internal/streams/destroy:169:8)
hoppscotch-aio       | Backend Server |     at emitErrorCloseNT (node:internal/streams/destroy:128:3)
hoppscotch-aio       | Backend Server |     at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

The server is behind a proxy and the problem is that the backend directly request the Microsoft Auth Servers, which is not possible.

Steps to reproduce

!! All behind a Proxy !!

  1. Setup .env with microsoft auth
  2. Host the newest Hoppscotch AIO Version 2025.1.0 on Docker
  3. Try to login

Environment

Production

Version

Self-hosted

Originally created by @MassBklf on GitHub (Feb 7, 2025). Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/4735 ### Is there an existing issue for this? - [x] I have searched the existing issues ### Current behavior When I try a login via Microsoft SSO, I get a 500 server error. Browserlog: ``` statusCode | 500 message | "Internal server error" ``` Serverlog: ``` hoppscotch-aio | Backend Server | [Nest] 37 - 02/07/2025, 10:06:39 AM ERROR [ExceptionsHandler] Failed to obtain access token hoppscotch-aio | Backend Server | InternalOAuthError: Failed to obtain access token hoppscotch-aio | Backend Server | at OAuth2Strategy._createOAuthError (/dist/backend/node_modules/.pnpm/passport-oauth2@1.8.0/node_modules/passport-oauth2/lib/strategy.js:423:17) hoppscotch-aio | Backend Server | at /dist/backend/node_modules/.pnpm/passport-oauth2@1.8.0/node_modules/passport-oauth2/lib/strategy.js:177:45 hoppscotch-aio | Backend Server | at /dist/backend/node_modules/.pnpm/oauth@0.10.0/node_modules/oauth/lib/oauth2.js:196:18 hoppscotch-aio | Backend Server | at ClientRequest.<anonymous> (/dist/backend/node_modules/.pnpm/oauth@0.10.0/node_modules/oauth/lib/oauth2.js:166:7) hoppscotch-aio | Backend Server | at ClientRequest.emit (node:events:519:28) hoppscotch-aio | Backend Server | at TLSSocket.socketErrorListener (node:_http_client:500:9) hoppscotch-aio | Backend Server | at TLSSocket.emit (node:events:519:28) hoppscotch-aio | Backend Server | at emitErrorNT (node:internal/streams/destroy:169:8) hoppscotch-aio | Backend Server | at emitErrorCloseNT (node:internal/streams/destroy:128:3) hoppscotch-aio | Backend Server | at process.processTicksAndRejections (node:internal/process/task_queues:82:21) ``` The server is behind a proxy and the problem is that the backend directly request the Microsoft Auth Servers, which is not possible. ### Steps to reproduce !! All behind a Proxy !! 1. Setup .env with microsoft auth 2. Host the newest Hoppscotch AIO Version 2025.1.0 on Docker 3. Try to login ### Environment Production ### Version Self-hosted
Author
Owner

@ericciccone commented on GitHub (Mar 31, 2025):

can you post your microsoft.strategy.js

<!-- gh-comment-id:2767048544 --> @ericciccone commented on GitHub (Mar 31, 2025): can you post your microsoft.strategy.js
Author
Owner

@MatthiasSalonkee commented on GitHub (Oct 31, 2025):

Hi,
I'm having the same issue but with github auth
The authentication works well, the user is connected, but the callback requests fails with 500 :

Backend Server \| ::ffff:127.0.0.1 GET /v1/auth/github/callback?code=xxx&state=xxx 500 - 170.928 ms 
Backend Server \| [Nest] 69 - 10/31/2025, 8:14:34 AM  ERROR [ExceptionsHandler] Error: Failed to obtain access token
Backend Server \| at /dist/backend/node_modules/.pnpm/passport-oauth2@1.8.0/node_modules/passport-oauth2/lib/strategy.js:178:49
Backend Server \| at /dist/backend/node_modules/.pnpm/oauth@0.10.0/node_modules/oauth/lib/oauth2.js:214:7
Backend Server \| at passBackControl (/dist/backend/node_modules/.pnpm/oauth@0.10.0/node_modules/oauth/lib/oauth2.js:134:9)
Backend Server \| at IncomingMessage.<anonymous> (/dist/backend/node_modules/.pnpm/oauth@0.10.0/node_modules/oauth/lib/oauth2.js:157:7)
Backend Server \|  at IncomingMessage.emit (node:events:530:35)
Backend Server \|  at endReadableNT (node:internal/streams/readable:1698:12)
Backend Server \|  at process.processTicksAndRejections (node:internal/process/task_queues:90:21)

Did anyone found the root cause and a fix ?

<!-- gh-comment-id:3471800612 --> @MatthiasSalonkee commented on GitHub (Oct 31, 2025): Hi, I'm having the same issue but with github auth The authentication works well, the user is connected, but the callback requests fails with 500 : ``` Backend Server \| ::ffff:127.0.0.1 GET /v1/auth/github/callback?code=xxx&state=xxx 500 - 170.928 ms Backend Server \| [Nest] 69 - 10/31/2025, 8:14:34 AM  ERROR [ExceptionsHandler] Error: Failed to obtain access token Backend Server \| at /dist/backend/node_modules/.pnpm/passport-oauth2@1.8.0/node_modules/passport-oauth2/lib/strategy.js:178:49 Backend Server \| at /dist/backend/node_modules/.pnpm/oauth@0.10.0/node_modules/oauth/lib/oauth2.js:214:7 Backend Server \| at passBackControl (/dist/backend/node_modules/.pnpm/oauth@0.10.0/node_modules/oauth/lib/oauth2.js:134:9) Backend Server \| at IncomingMessage.<anonymous> (/dist/backend/node_modules/.pnpm/oauth@0.10.0/node_modules/oauth/lib/oauth2.js:157:7) Backend Server \|  at IncomingMessage.emit (node:events:530:35) Backend Server \|  at endReadableNT (node:internal/streams/readable:1698:12) Backend Server \|  at process.processTicksAndRejections (node:internal/process/task_queues:90:21) ``` Did anyone found the root cause and a fix ?
Author
Owner

@EmperorArthur commented on GitHub (Nov 19, 2025):

@MassBklf This may be related to #5598, with the proxy failure masking the 400 error being returned by Azure.

<!-- gh-comment-id:3554874370 --> @EmperorArthur commented on GitHub (Nov 19, 2025): @MassBklf This may be related to #5598, with the proxy failure masking the 400 error being returned by Azure.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#1769
No description provided.