MCPcopy Create free account
hub / github.com/authlib/authlib / AsyncOAuth1Client

Class AsyncOAuth1Client

authlib/integrations/httpx_client/oauth1_client.py:34–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32
33
34class AsyncOAuth1Client(_OAuth1Client, httpx2.AsyncClient):
35 auth_class = OAuth1Auth
36
37 def __init__(
38 self,
39 client_id,
40 client_secret=None,
41 token=None,
42 token_secret=None,
43 redirect_uri=None,
44 rsa_key=None,
45 verifier=None,
46 signature_method=SIGNATURE_HMAC_SHA1,
47 signature_type=SIGNATURE_TYPE_HEADER,
48 force_include_body=False,
49 **kwargs,
50 ):
51 _client_kwargs = extract_client_kwargs(kwargs)
52 httpx2.AsyncClient.__init__(self, **_client_kwargs)
53
54 _OAuth1Client.__init__(
55 self,
56 None,
57 client_id=client_id,
58 client_secret=client_secret,
59 token=token,
60 token_secret=token_secret,
61 redirect_uri=redirect_uri,
62 rsa_key=rsa_key,
63 verifier=verifier,
64 signature_method=signature_method,
65 signature_type=signature_type,
66 force_include_body=force_include_body,
67 **kwargs,
68 )
69
70 async def fetch_access_token(self, url, verifier=None, **kwargs):
71 """Method for fetching an access token from the token endpoint.
72
73 This is the final step in the OAuth 1 workflow. An access token is
74 obtained using all previously obtained credentials, including the
75 verifier from the authorization step.
76
77 :param url: Access Token endpoint.
78 :param verifier: A verifier string to prove authorization was granted.
79 :param kwargs: Extra parameters to include for fetching access token.
80 :return: A token dict.
81 """
82 if verifier:
83 self.auth.verifier = verifier
84 if not self.auth.verifier:
85 self.handle_error("missing_verifier", 'Missing "verifier" value')
86 token = await self._fetch_token(url, **kwargs)
87 self.auth.verifier = None
88 return token
89
90 async def _fetch_token(self, url, **kwargs):
91 resp = await self.post(url, **kwargs)

Callers 7

test_fetch_access_tokenFunction · 0.90
test_get_via_headerFunction · 0.90
test_get_via_bodyFunction · 0.90
test_get_via_queryFunction · 0.90

Calls

no outgoing calls

Tested by 7

test_fetch_access_tokenFunction · 0.72
test_get_via_headerFunction · 0.72
test_get_via_bodyFunction · 0.72
test_get_via_queryFunction · 0.72