sources/oauth: fix handling of token for do_request
This commit is contained in:
parent
2b9705b33c
commit
2be6cd70d9
|
@ -40,7 +40,7 @@ class BaseOAuthClient:
|
|||
def get_profile_info(self, token: Dict[str, str]) -> Optional[Dict[str, Any]]:
|
||||
"Fetch user profile information."
|
||||
try:
|
||||
response = self.do_request("get", self.source.profile_url, token=token,)
|
||||
response = self.do_request("get", self.source.profile_url, token=token)
|
||||
response.raise_for_status()
|
||||
except RequestException as exc:
|
||||
LOGGER.warning("Unable to fetch user profile", exc=exc)
|
||||
|
|
|
@ -76,9 +76,6 @@ class OAuthClient(BaseOAuthClient):
|
|||
def parse_raw_token(self, raw_token: str) -> Dict[str, Any]:
|
||||
"Parse token and secret from raw token response."
|
||||
return dict(parse_qsl(raw_token))
|
||||
# token = query_string["oauth_token"]
|
||||
# secret = query_string["oauth_token_secret"]
|
||||
# return (token, secret)
|
||||
|
||||
def do_request(self, method: str, url: str, **kwargs) -> Response:
|
||||
"Build remote url request. Constructs necessary auth."
|
||||
|
|
|
@ -97,7 +97,7 @@ class OAuth2Client(BaseOAuthClient):
|
|||
def do_request(self, method: str, url: str, **kwargs) -> Response:
|
||||
"Build remote url request. Constructs necessary auth."
|
||||
if "token" in kwargs:
|
||||
token = self.parse_raw_token(kwargs.pop("token"))
|
||||
token = kwargs.pop("token")
|
||||
|
||||
params = kwargs.get("params", {})
|
||||
params["access_token"] = token["access_token"]
|
||||
|
@ -105,6 +105,7 @@ class OAuth2Client(BaseOAuthClient):
|
|||
|
||||
headers = kwargs.get("headers", {})
|
||||
headers["Authorization"] = f"{token['token_type']} {token['access_token']}"
|
||||
kwargs["headers"] = headers
|
||||
return super().do_request(method, url, **kwargs)
|
||||
|
||||
@property
|
||||
|
|
Reference in New Issue