feat(auth): allow updating custom fields from oauth, update MojeID

This commit is contained in:
2025-10-11 20:34:36 +02:00
parent df0f2584ae
commit 32764ab1b0
3 changed files with 47 additions and 11 deletions

View File

@@ -1,11 +1,10 @@
import json
from typing import Optional, Literal
from typing import Optional, Literal, Any
from httpx_oauth.clients.openid import OpenID
from httpx_oauth.oauth2 import OAuth2Token, GetAccessTokenError, T
from httpx_oauth.oauth2 import T
# claims=%7B%22id_token%22%3A%7B%22birthdate%22%3A%7B%22essential%22%3Atrue%7D%2C%22name%22%3A%7B%22essential%22%3Atrue%7D%2C%22given_name%22%3A%7B%22essential%22%3Atrue%7D%2C%22family_name%22%3A%7B%22essential%22%3Atrue%7D%2C%22email%22%3A%7B%22essential%22%3Atrue%7D%2C%22address%22%3A%7B%22essential%22%3Afalse%7D%2C%22mojeid_valid%22%3A%7B%22essential%22%3Atrue%7D%7D%7D
class MojeIDOAuth(OpenID):
def __init__(self, client_id: str, client_secret: str):
super().__init__(
@@ -16,6 +15,14 @@ class MojeIDOAuth(OpenID):
base_scopes=["openid", "email", "profile"],
)
async def get_user_info(self, token: str) -> Optional[Any]:
info = await self.get_profile(token)
return {
"first_name": info.get("given_name"),
"last_name": info.get("family_name"),
}
async def get_authorization_url(
self,
redirect_uri: str,