Unable to complete OAuth login - Immich & Authentik

Hi! So I'm setting up OAuth login. I'm using Authentik. I created an OAuth2/OpenID Provider and Application using the docs. The button to login with OAuth shows up and I get redirected correctly to Authentik. I'm prompted for my username, password, then a consent screen for using my email.. I'm then redirected back to Immich and the URL changes <immich>/auth/login?code=xxxxxx&state=xxxxxxxxx But then the login fails, I'm back at the Immich login and the text "Unable to complete OAuth login" appears. I found the following error in the Immich server log:
[Nest] 7 - 12/21/2022, 6:37:04 PM ERROR [ExceptionsHandler] outgoing request timed out after 3500ms
RPError: outgoing request timed out after 3500ms
at /usr/src/app/node_modules/openid-client/lib/helpers/request.js:137:13
at async Client.grant (/usr/src/app/node_modules/openid-client/lib/client.js:1316:22)
at async Client.callback (/usr/src/app/node_modules/openid-client/lib/client.js:476:24)
at async OAuthService.callback (/usr/src/app/dist/apps/immich/apps/immich/src/api-v1/oauth/oauth.service.js:46:24)
at async OAuthController.callback (/usr/src/app/dist/apps/immich/apps/immich/src/api-v1/oauth/oauth.controller.js:33:31)
at async /usr/src/app/node_modules/@nestjs/core/router/router-execution-context.js:46:28
at async /usr/src/app/node_modules/@nestjs/core/router/router-proxy.js:9:17
[Nest] 7 - 12/21/2022, 6:37:04 PM ERROR [ExceptionsHandler] outgoing request timed out after 3500ms
RPError: outgoing request timed out after 3500ms
at /usr/src/app/node_modules/openid-client/lib/helpers/request.js:137:13
at async Client.grant (/usr/src/app/node_modules/openid-client/lib/client.js:1316:22)
at async Client.callback (/usr/src/app/node_modules/openid-client/lib/client.js:476:24)
at async OAuthService.callback (/usr/src/app/dist/apps/immich/apps/immich/src/api-v1/oauth/oauth.service.js:46:24)
at async OAuthController.callback (/usr/src/app/dist/apps/immich/apps/immich/src/api-v1/oauth/oauth.controller.js:33:31)
at async /usr/src/app/node_modules/@nestjs/core/router/router-execution-context.js:46:28
at async /usr/src/app/node_modules/@nestjs/core/router/router-proxy.js:9:17
I can't figure out why there is a time out and at what part of the login flow. Is it a connection / firewall issue?
13 Replies
jrasm91
jrasm913y ago
The code/state from the url are sent to immich, who then sends them in a request to authentik for verification. The library we're using to implement this request waits for a response from authentik for 3.5 seconds and then throw this error. Everything might be working fine, it's just if the response is delayed this error happens. The first half of this process working implies that there isn't a network reachability issues, since the discovery process worked. So this is specific to the callback request just taking too long. @stijnos Are you using docker? Can you try switching out the release tag on the immich-server for tag 1155? It should have a timeout of 30 seconds and we can see if that does anything different.
stijnos
stijnosOP3y ago
I can confirm it’s working perfectly now!!! So it really was a timeout. Thank you @jrasm91
jrasm91
jrasm913y ago
Sweet - it would still be interesting to know why it's taking so long lol.
stijnos
stijnosOP3y ago
Agreed. Do you think an increased timeout will make it to a release?
jrasm91
jrasm913y ago
I was thinking about the best way to solve it the "right way", but I think a blanket 30 second timeout might be good enough. The other options are making it configurable, but I'm not sure if that's worth the effort or not.
stijnos
stijnosOP3y ago
Maybe the right fix is on me. I can clean installing my Authentik. However, not really a fan of doing that at this point in time. I'm daily driving it with some important stuff to me. That would be a holiday project. If the 30 second window fixes it for now it would definitely solve my problem!
jrasm91
jrasm913y ago
I don't see much downside to increasing the timeout. It's a timeout just for these oauth calls, which are restricted to logging in, so it's not a high volume call or anything.
stijnos
stijnosOP3y ago
From a security perspective I don't see other issues.
jrasm91
jrasm913y ago
I changed the PR to ready to review. It'll probably be in the next release. Merged!
John
John3y ago
I'm using TrueCharts - where would this setting be? Appreciate the help!! This is my error:
2022-12-30 03:54:22.709308+00:00RPError: outgoing request timed out after 3500ms
2022-12-30 03:54:22.709361+00:00at /usr/src/app/node_modules/openid-client/lib/helpers/request.js:137:13
2022-12-30 03:54:22.709379+00:00at async Client.grant (/usr/src/app/node_modules/openid-client/lib/client.js:1316:22)
2022-12-30 03:54:22.709393+00:00at async Client.callback (/usr/src/app/node_modules/openid-client/lib/client.js:476:24)
2022-12-30 03:54:22.709420+00:00at async OAuthService.callback (/usr/src/app/dist/apps/immich/apps/immich/src/api-v1/oauth/oauth.service.js:46:24)
2022-12-30 03:54:22.709436+00:00at async OAuthController.callback (/usr/src/app/dist/apps/immich/apps/immich/src/api-v1/oauth/oauth.controller.js:33:31)
2022-12-30 03:54:22.709450+00:00at async /usr/src/app/node_modules/@nestjs/core/router/router-execution-context.js:46:28
2022-12-30 03:54:22.709308+00:00RPError: outgoing request timed out after 3500ms
2022-12-30 03:54:22.709361+00:00at /usr/src/app/node_modules/openid-client/lib/helpers/request.js:137:13
2022-12-30 03:54:22.709379+00:00at async Client.grant (/usr/src/app/node_modules/openid-client/lib/client.js:1316:22)
2022-12-30 03:54:22.709393+00:00at async Client.callback (/usr/src/app/node_modules/openid-client/lib/client.js:476:24)
2022-12-30 03:54:22.709420+00:00at async OAuthService.callback (/usr/src/app/dist/apps/immich/apps/immich/src/api-v1/oauth/oauth.service.js:46:24)
2022-12-30 03:54:22.709436+00:00at async OAuthController.callback (/usr/src/app/dist/apps/immich/apps/immich/src/api-v1/oauth/oauth.controller.js:33:31)
2022-12-30 03:54:22.709450+00:00at async /usr/src/app/node_modules/@nestjs/core/router/router-execution-context.js:46:28
John
John3y ago
No description
jrasm91
jrasm913y ago
3500ms implies you are still using an old version. The current timeout is 30s, so just pull the latest version and try again. The server should be on atleast v1.40.0.
John
John3y ago
Sounds good, I'm using helm charts by TrueCharts for TrueNAS Scale so I need to wait until they update it. Thanks for the help!

Did you find this page helpful?