Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Zahra Rajabi
tweepy
Commits
37129ca9
Commit
37129ca9
authored
Aug 10, 2009
by
Josh Roesslein
Browse files
Update tutorial 1 to demo storing/loading oauth token via pickle.
parent
8447abef
Changes
1
Hide whitespace changes
Inline
Side-by-side
tutorial/t1.py
View file @
37129ca9
from
getpass
import
getpass
import
cPickle
as
pickle
import
tweepy
""" Tutorial 1 -- Authentication
...
...
@@ -51,14 +52,24 @@ oauth_auth.get_access_token(verifier)
Okay we are all set then with OAuth. If you want to store the access
token for later use, here's how...
"""
access_token
_store
=
oauth_auth
.
access_token
print
'Access token: %s'
%
access_token
_store
access_token
=
oauth_auth
.
access_token
print
'Access token: %s'
%
access_token
"""
And to re-create the OAuthHandler with that access token later on..
.
For later use we will keep the token pickled into a file
.
"""
token_file
=
open
(
'oauth_token'
,
'wb'
)
pickle
.
dump
(
access_token
,
token_file
)
token_file
.
close
()
"""
And to reload the token...
"""
token_file
=
open
(
'oauth_token'
,
'rb'
)
oauth_token
=
pickle
.
load
(
token_file
)
token_file
.
close
()
oauth_auth
=
tweepy
.
OAuthHandler
(
consumer_key
,
consumer_secret
)
oauth_auth
.
access_token
=
access_token
_store
oauth_auth
.
access_token
=
access_token
"""
Now let's plugin our newly created auth handler into an API instance
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment