Skip to content

Commit

Permalink
Merge pull request #522 from PaulWay/paulway_oauth2_worker_docs_fixes
Browse files Browse the repository at this point in the history
Put OAuth2Session in 'oauth' consistently in examples
  • Loading branch information
JonathanHuot authored Feb 25, 2024
2 parents 206f8e5 + c61d1a0 commit 424adf0
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions docs/oauth2_workflow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,13 @@ is necessary but refreshing is done manually.
>>> from requests_oauthlib import OAuth2Session
>>> from oauthlib.oauth2 import TokenExpiredError
>>> try:
... client = OAuth2Session(client_id, token=token)
... r = client.get(protected_url)
... oauth = OAuth2Session(client_id, token=token)
... r = oauth.get(protected_url)
>>> except TokenExpiredError as e:
... token = client.refresh_token(refresh_url, **extra)
... token = oauth.refresh_token(refresh_url, **extra)
... token_saver(token)
>>> client = OAuth2Session(client_id, token=token)
>>> r = client.get(protected_url)
>>> oauth = OAuth2Session(client_id, token=token)
>>> r = oauth.get(protected_url)
(Second) Define automatic token refresh automatic but update manually
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -268,9 +268,9 @@ is done manually.
>>> from requests_oauthlib import OAuth2Session, TokenUpdated
>>> try:
... client = OAuth2Session(client_id, token=token,
... oauth = OAuth2Session(client_id, token=token,
... auto_refresh_kwargs=extra, auto_refresh_url=refresh_url)
... r = client.get(protected_url)
... r = oauth.get(protected_url)
>>> except TokenUpdated as e:
... token_saver(e.token)
Expand All @@ -284,9 +284,9 @@ however that you still need to update ``expires_in`` to trigger the refresh.
.. code-block:: pycon
>>> from requests_oauthlib import OAuth2Session
>>> client = OAuth2Session(client_id, token=token, auto_refresh_url=refresh_url,
>>> oauth = OAuth2Session(client_id, token=token, auto_refresh_url=refresh_url,
... auto_refresh_kwargs=extra, token_updater=token_saver)
>>> r = client.get(protected_url)
>>> r = oauth.get(protected_url)
TLS Client Authentication
-------------------------
Expand Down

0 comments on commit 424adf0

Please sign in to comment.