Skip to content

Commit 2d6ce18

Browse files
committed
Make endpoint methods as an alternative choice
1 parent 70d4aba commit 2d6ce18

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/fastapi_oauth2/core.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import os
21
import json
2+
import os
33
import random
44
import re
55
import string
@@ -34,9 +34,8 @@ def absolute_uri(self, path=None) -> str:
3434
return path
3535

3636
def get_setting(self, name) -> Any:
37-
""" settings from environment """
3837
value = os.getenv(name)
39-
if value == None:
38+
if value is None:
4039
raise KeyError
4140
return value
4241

@@ -69,8 +68,8 @@ def __init__(self, client: OAuth2Client) -> None:
6968
self.provider = client.backend.name
7069
self.redirect_uri = client.redirect_uri
7170
self.backend = client.backend(OAuth2Strategy())
72-
self._authorization_endpoint = self.backend.authorization_url() if hasattr(self.backend, 'authorization_url') else self.backend.AUTHORIZATION_URL
73-
self._token_endpoint = self.backend.access_token_url() if hasattr(self.backend, 'access_token_url') else self.backend.ACCESS_TOKEN_URL
71+
self._authorization_endpoint = client.backend.AUTHORIZATION_URL or self.backend.authorization_url()
72+
self._token_endpoint = client.backend.ACCESS_TOKEN_URL or self.backend.access_token_url()
7473
self._oauth_client = WebApplicationClient(self.client_id)
7574

7675
@property

0 commit comments

Comments
 (0)