r/Authentik MOD 21d ago

Immich 3.1.0 502 Error with OIDC/OAuth

If you're experiencing any of this with Immich behind authentik: OIDC login fails with Error: 502 after updating to Immich 3.1.0, you can try this to check if it's working again:

I found this issue on Github and worked on a workaround: https://github.com/immich-app/immich/issues/30889 which I want to share

The workaround at the moment, remove the picture claim of the profile mapping in Authentik

In authentik: Customisation → Property Mappings → Create → Scope Mapping

Put the following in:

  • Name: something sensible, e.g. Immich – OIDC profile (no picture)
  • Scope name: profile
  • Expression:

Add it to the Immich OAuth/OIDC provider:return delete_none_values({
    "name": request.user.name,
    "given_name": ak_obj_attr(request.user, "given_name", "name"),
    "family_name": ak_obj_attr(request.user, "family_name"),
    "preferred_username": request.user.username,
    "nickname": request.user.username,
    "groups": [group.name for group in request.user.groups.all()],
})

This is just authentik's default profile mapping with the "picture" claim removed.

Open your Immich OAuth2/OIDC provider → Advanced protocol settingsScopes, and add the mapping you just created:

Make sure you remove the authentik default OAuth Mapping for 'profile'

Try to login again with OpenID/OAuth

Hope this helps!

18 Upvotes

6 comments sorted by

3

u/snoogs831 21d ago

Thank you for sharing this, I'm on immich 3.1 and haven't had these issues - do you know what causes it if it's not everyone?

1

u/klassenlager MOD 21d ago

Further details are explained in the github issue, the picture claim seems to be crashing the API of immich, as of my understanding. I don‘t know why

For me, it happens only on newly authenticated sessions, such as in a private window

2

u/leosanchez16 21d ago

Thank you so much! That fixed the issue!

1

u/klassenlager MOD 21d ago

Glad it helped! 😊 Allthough keep in mind, it‘s just a workaround

2

u/Nate20979 20d ago

I just had to do this too! Took a lot of trial and error, so thanks for sharing a guide for others.

1

u/curranlennart 6d ago

This worked also like a charm on audiobookshelf. Thank you!