goauthentik / goauthentik/authentik

Is there a possibility to use a custom (non-standard) field from an OAuth source to be mapped to the users id?

Open
#14,669 6 comments 1 reaction 0 assignees View on GitHub
question
Dominant language
Python
Stars
25.6k
Forks
2k
Avg merge
1d 1h
Merged PRs (30d)
644

Description

**Describe your question/**
I am trying to set up an external OAuth Provider, failing because the standard is not properly met.
We need to use this provider as we are part of a larger network and fetch user data from their database.
However, users in this network are not identified by an "id" but by a "cid".

Is there any way for me to make authentik use this field instead of the non-existent "id" field?
Can i use any workaround or is this use case not supported by authentik?

**Relevant info**
The "OAuth" provider features authorize, token and userdata endpoints, but nothing else. The cid returned by the userdata endpoint is found in an object that looks like this:

```
{
data: {
...
cid: string
...
}
}
```

**Screenshots**

![Image](https://github.com/user-attachments/assets/9518ade7-9bb6-406f-ad87-5c391fe2745b)
This is the error that is being shown

**Logs**
I was unable to get any logs, even through using policies, as it appears that this check comes before any of the validations takes place, so i don't really see how to even remap the field before the get_user_id function is being called.

**Version and Deployment (please complete the following information):**

- authentik version: 2025.4.1
- Deployment: docker compose

**Additional context**
I found the error is being thrown in the oauth/views/callback.py OAuthCallback class, and as far as i can see (i'm no python programmer) it appears that the callback statically checks for the 'id' field, but i don't see any way to inject the id before it actually does that check.

Happy to share any helpful information!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.