mirror of
https://github.com/dat515-2025/Group-8.git
synced 2026-03-22 15:12:08 +01:00
feat(auth): allow updating custom fields from oauth, update MojeID
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user