File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -288,4 +288,16 @@ however that you still need to update ``expires_in`` to trigger the refresh.
288288 ... auto_refresh_kwargs=extra, token_updater=token_saver)
289289 >>> r = client.get(protected_url)
290290
291+ TLS Client Authentication
292+ -------------------------
293+
294+ To use TLS Client Authentication (draft-ietf-oauth-mtls) via a
295+ self-signed or CA-issued certificate, pass the certificate in the
296+ token request and ensure that the client id is sent in the request:
297+
298+ .. code-block :: pycon
299+
300+ >>> oauth.fetch_token(token_url='https://somesite.com/oauth2/token',
301+ ... include_client_id=True, cert=('test-client.pem', 'test-client-key.pem'))
302+
291303 .. _write this section : https://github.com/requests/requests-oauthlib/issues/48
Original file line number Diff line number Diff line change @@ -189,6 +189,7 @@ def fetch_token(
189189 proxies = None ,
190190 include_client_id = None ,
191191 client_secret = None ,
192+ cert = None ,
192193 ** kwargs
193194 ):
194195 """Generic method for fetching an access token from the token endpoint.
@@ -229,6 +230,10 @@ def fetch_token(
229230 `auth` tuple. If the value is `None`, it will be
230231 omitted from the request, however if the value is
231232 an empty string, an empty string will be sent.
233+ :param cert: Client certificate to send for OAuth 2.0 Mutual-TLS Client
234+ Authentication (draft-ietf-oauth-mtls). Can either be the
235+ path of a file containing the private key and certificate or
236+ a tuple of two filenames for certificate and key.
232237 :param kwargs: Extra parameters to include in the token request.
233238 :return: A token dict
234239 """
@@ -341,6 +346,7 @@ def fetch_token(
341346 auth = auth ,
342347 verify = verify ,
343348 proxies = proxies ,
349+ cert = cert ,
344350 ** request_kwargs
345351 )
346352
You can’t perform that action at this time.
0 commit comments