Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #333 #334

Merged
merged 2 commits into from
Aug 19, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions httpx_oauth/clients/openid.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from typing import Any, Dict, List, Optional, Tuple
from typing import Any, Dict, List, Optional, Tuple, get_args

import httpx

from httpx_oauth.exceptions import GetIdEmailError
from httpx_oauth.oauth2 import BaseOAuth2, OAuth2RequestError
from httpx_oauth.oauth2 import BaseOAuth2, OAuth2ClientAuthMethod, OAuth2RequestError

BASE_SCOPES = ["openid", "email"]

Expand Down Expand Up @@ -70,6 +70,19 @@ def __init__(
"revocation_endpoint_auth_methods_supported", ["client_secret_basic"]
)

supported_auth_methods = get_args(OAuth2ClientAuthMethod)
# check if there is any supported and select the first one
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's clever 👍

token_endpoint_auth_methods_supported = [
method
for method in token_endpoint_auth_methods_supported
if method in supported_auth_methods
]
revocation_endpoint_auth_methods_supported = [
method
for method in revocation_endpoint_auth_methods_supported
if method in supported_auth_methods
]

super().__init__(
client_id,
client_secret,
Expand All @@ -80,11 +93,11 @@ def __init__(
name=name,
base_scopes=base_scopes,
token_endpoint_auth_method=token_endpoint_auth_methods_supported[0],
revocation_endpoint_auth_method=revocation_endpoint_auth_methods_supported[
0
]
if revocation_endpoint
else None,
revocation_endpoint_auth_method=(
revocation_endpoint_auth_methods_supported[0]
if revocation_endpoint
else None
),
)

async def get_id_email(self, token: str) -> Tuple[str, Optional[str]]:
Expand Down
Loading