Skip to content

Commit 637b2ee

Browse files
dosisodJonathanHuot
authored andcommitted
Update Python 2 examples in docs to Python 3
1 parent 68c2841 commit 637b2ee

File tree

7 files changed

+24
-24
lines changed

7 files changed

+24
-24
lines changed

docs/examples/bitbucket.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ try out the command line interactive example below.
2727
2828
>>> # 3. Redirect user to Bitbucket for authorization
2929
>>> authorization_url = bitbucket.authorization_url(authorization_base_url)
30-
>>> print 'Please go here and authorize,', authorization_url
30+
>>> print('Please go here and authorize,', authorization_url)
3131
3232
>>> # 4. Get the authorization verifier code from the callback url
33-
>>> redirect_response = raw_input('Paste the full redirect URL here:')
33+
>>> redirect_response = input('Paste the full redirect URL here:')
3434
>>> bitbucket.parse_authorization_response(redirect_response)
3535
3636
>>> # 5. Fetch the access token
3737
>>> bitbucket.fetch_access_token(access_token_url)
3838
3939
>>> # 6. Fetch a protected resource, i.e. user profile
4040
>>> r = bitbucket.get('https://bitbucket.org/api/1.0/user')
41-
>>> print r.content
41+
>>> print(r.content)

docs/examples/facebook.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ a callback URL then you can try out the command line interactive example below.
2525
2626
>>> # Redirect user to Facebook for authorization
2727
>>> authorization_url, state = facebook.authorization_url(authorization_base_url)
28-
>>> print 'Please go here and authorize,', authorization_url
28+
>>> print('Please go here and authorize,', authorization_url)
2929
3030
>>> # Get the authorization verifier code from the callback url
31-
>>> redirect_response = raw_input('Paste the full redirect URL here:')
31+
>>> redirect_response = input('Paste the full redirect URL here:')
3232
3333
>>> # Fetch the access token
3434
>>> facebook.fetch_token(token_url, client_secret=client_secret,
3535
..> authorization_response=redirect_response)
3636
3737
>>> # Fetch a protected resource, i.e. user profile
3838
>>> r = facebook.get('https://graph.facebook.com/me?')
39-
>>> print r.content
39+
>>> print(r.content)

docs/examples/github.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ command line interactive example below.
2222
2323
>>> # Redirect user to GitHub for authorization
2424
>>> authorization_url, state = github.authorization_url(authorization_base_url)
25-
>>> print 'Please go here and authorize,', authorization_url
25+
>>> print('Please go here and authorize,', authorization_url)
2626
2727
>>> # Get the authorization verifier code from the callback url
28-
>>> redirect_response = raw_input('Paste the full redirect URL here:')
28+
>>> redirect_response = input('Paste the full redirect URL here:')
2929
3030
>>> # Fetch the access token
3131
>>> github.fetch_token(token_url, client_secret=client_secret,
3232
>>> authorization_response=redirect_response)
3333
3434
>>> # Fetch a protected resource, i.e. user profile
3535
>>> r = github.get('https://api.github.com/user')
36-
>>> print r.content
36+
>>> print(r.content)

docs/examples/tumblr.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ Enter a call back url (can just be http://www.tumblr.com/dashboard) and get the
2424
2525
>>> # Link user to authorization page
2626
>>> authorization_url = tumblr.authorization_url(authorization_base_url)
27-
>>> print 'Please go here and authorize,', authorization_url
27+
>>> print('Please go here and authorize,', authorization_url)
2828
2929
>>> # Get the verifier code from the URL
30-
>>> redirect_response = raw_input('Paste the full redirect URL here: ')
30+
>>> redirect_response = input('Paste the full redirect URL here: ')
3131
>>> tumblr.parse_authorization_response(redirect_response)
3232
3333
>>> # Fetch the access token
3434
>>> tumblr.fetch_access_token(access_token_url)
3535
3636
>>> # Fetch a protected resource
37-
>>> print tumblr.get('http://api.tumblr.com/v2/user/dashboard')
37+
>>> print(tumblr.get('http://api.tumblr.com/v2/user/dashboard'))

docs/oauth1_workflow.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ Workflow example showing use of both OAuth1 and OAuth1Session
7171
7272
>>> # Using OAuth1Session
7373
>>> authorization_url = oauth.authorization_url(base_authorization_url)
74-
>>> print 'Please go here and authorize,', authorization_url
75-
>>> redirect_response = raw_input('Paste the full redirect URL here: ')
74+
>>> print('Please go here and authorize,', authorization_url)
75+
>>> redirect_response = input('Paste the full redirect URL here: ')
7676
>>> oauth_response = oauth.parse_authorization_response(redirect_response)
7777
{
7878
"oauth_token": "Z6eEdO8MOmk394WozF5oKyuAv855l4Mlqo7hhlSLik",
@@ -83,8 +83,8 @@ Workflow example showing use of both OAuth1 and OAuth1Session
8383
>>> # Using OAuth1 auth helper
8484
>>> authorize_url = base_authorization_url + '?oauth_token='
8585
>>> authorize_url = authorize_url + resource_owner_key
86-
>>> print 'Please go here and authorize,', authorize_url
87-
>>> verifier = raw_input('Please input the verifier')
86+
>>> print('Please go here and authorize,', authorize_url)
87+
>>> verifier = input('Please input the verifier')
8888
8989
3. Obtain an access token from the OAuth provider. Save this token as it can be
9090
re-used later. In this step we will re-use most of the credentials obtained
@@ -153,12 +153,12 @@ OAuth takes many forms, so let's take a look at a few different forms:
153153
import requests
154154
from requests_oauthlib import OAuth1
155155
156-
url = u'https://api.twitter.com/1/account/settings.json'
156+
url = 'https://api.twitter.com/1/account/settings.json'
157157
158-
client_key = u'...'
159-
client_secret = u'...'
160-
resource_owner_key = u'...'
161-
resource_owner_secret = u'...'
158+
client_key = '...'
159+
client_secret = '...'
160+
resource_owner_key = '...'
161+
resource_owner_secret = '...'
162162
163163
164164
Header signing (recommended):

docs/oauth2_workflow.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ the provider is Google and the protected resource is the user's profile.
7272
# parameters.
7373
access_type="offline", prompt="select_account")
7474
75-
>>> print 'Please go to %s and authorize access.' % authorization_url
76-
>>> authorization_response = raw_input('Enter the full callback URL')
75+
>>> print(f'Please go to {authorization_url} and authorize access.')
76+
>>> authorization_response = input('Enter the full callback URL')
7777
7878
2. Fetch an access token from the provider using the authorization code
7979
obtained during user authorization.

requests_oauthlib/oauth1_session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class OAuth1Session(requests.Session):
8585
'https://api.twitter.com/oauth/authorize?oauth_token=sdf0o9823sjdfsdf&oauth_callback=https%3A%2F%2F127.0.0.1%2Fcallback'
8686
>>>
8787
>>> # Third step. Fetch the access token
88-
>>> redirect_response = raw_input('Paste the full redirect URL here.')
88+
>>> redirect_response = input('Paste the full redirect URL here.')
8989
>>> oauth_session.parse_authorization_response(redirect_response)
9090
{
9191
'oauth_token: 'kjerht2309u',

0 commit comments

Comments
 (0)