InternalOAuthError: Failed to obtain access token with nextcloud

Very similar to

My version of HedgeDoc is: 1.9.0. Running in docker with an nginx reverse proxy

What I expected to happen:

Successfully login with OAuth2 through nextcloud

What actually happened:

Client receives reply:

Internal Server Error

Server shows in the logs:

app_1  | InternalOAuthError: Failed to obtain access token
app_1  |     at OAuth2CustomStrategy.OAuth2Strategy._createOAuthError (/hedgedoc/node_modules/passport-oauth2/lib/strategy.js:408:17)
app_1  |     at /hedgedoc/node_modules/passport-oauth2/lib/strategy.js:175:45
app_1  |     at /hedgedoc/node_modules/oauth/lib/oauth2.js:191:18
app_1  |     at ClientRequest.<anonymous> (/hedgedoc/node_modules/oauth/lib/oauth2.js:162:5)
app_1  |     at ClientRequest.emit (node:events:394:28)
app_1  |     at TLSSocket.socketErrorListener (node:_http_client:447:9)
app_1  |     at TLSSocket.emit (node:events:394:28)
app_1  |     at emitErrorNT (node:internal/streams/destroy:157:8)
app_1  |     at emitErrorCloseNT (node:internal/streams/destroy:122:3)
app_1  |     at processTicksAndRejections (node:internal/process/task_queues:83:21)
app_1  | 2021-11-24T14:23:07.424Z info: - - [24/Nov/2021:14:23:07 +0000] "GET /auth/oauth2/callback?state=5Dj97DP5EjVPAGYJNSQIVIp6&code=6aVQMrtkanwXlzk180DfcLA4C0qJiZJXZVymXm7ZAjMEuuSKtyJg77KUGcZdBzBuxKOd7V5dqglsFwU7noCcF5vcm2w5GKUV8SehtlFViDE1X5ySaIhZchoHKNLQLPHy HTTP/1.1" 500 148 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0"
app_1  | 

I already tried:

The application appears as authorized in nextcloud, so I assume it is an issue retrieving the token.


      - CMD_OAUTH2_CLIENT_ID=xxx
      - CMD_OAUTH2_PROVIDERNAME=nextcloud

Hello @brunovianna

Can you reach your nextcloud instance from within the container? You should be able to verify that by using docker exec to enter the container and curl from inside the container.