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

Class OAuth1Session

authlib/integrations/requests_client/oauth1_session.py:27–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25
26
27class OAuth1Session(OAuth1Client, Session):
28 auth_class = OAuth1Auth
29
30 def __init__(
31 self,
32 client_id,
33 client_secret=None,
34 token=None,
35 token_secret=None,
36 redirect_uri=None,
37 rsa_key=None,
38 verifier=None,
39 signature_method=SIGNATURE_HMAC_SHA1,
40 signature_type=SIGNATURE_TYPE_HEADER,
41 force_include_body=False,
42 **kwargs,
43 ):
44 Session.__init__(self)
45 update_session_configure(self, kwargs)
46 OAuth1Client.__init__(
47 self,
48 session=self,
49 client_id=client_id,
50 client_secret=client_secret,
51 token=token,
52 token_secret=token_secret,
53 redirect_uri=redirect_uri,
54 rsa_key=rsa_key,
55 verifier=verifier,
56 signature_method=signature_method,
57 signature_type=signature_type,
58 force_include_body=force_include_body,
59 **kwargs,
60 )
61
62 def rebuild_auth(self, prepared_request, response):
63 """When being redirected we should always strip Authorization
64 header, since nonce may not be reused as per OAuth spec.
65 """
66 if "Authorization" in prepared_request.headers:
67 # If we get redirected to a new host, we should strip out
68 # any authentication headers.
69 prepared_request.headers.pop("Authorization", True)
70 prepared_request.prepare_auth(self.auth)
71
72 @staticmethod
73 def handle_error(error_type, error_description):
74 raise OAuthError(error_type, error_description)

Callers 15

test_no_client_idFunction · 0.90
test_signature_typesFunction · 0.90
test_signature_methodsFunction · 0.90
test_binary_uploadFunction · 0.90
test_nonasciiFunction · 0.90
test_redirect_uriFunction · 0.90
test_set_tokenFunction · 0.90
test_parse_response_urlFunction · 0.90
test_fetch_request_tokenFunction · 0.90
test_fetch_access_tokenFunction · 0.90

Calls

no outgoing calls

Tested by 15

test_no_client_idFunction · 0.72
test_signature_typesFunction · 0.72
test_signature_methodsFunction · 0.72
test_binary_uploadFunction · 0.72
test_nonasciiFunction · 0.72
test_redirect_uriFunction · 0.72
test_set_tokenFunction · 0.72
test_parse_response_urlFunction · 0.72
test_fetch_request_tokenFunction · 0.72
test_fetch_access_tokenFunction · 0.72