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
f30bf332
Commit
f30bf332
authored
Aug 17, 2013
by
Aaron Hill
Browse files
Merge branch 'master' into pull_coverage
parents
0bcbe3c8
280f8d85
Changes
3
Hide whitespace changes
Inline
Side-by-side
examples/basic_auth.py
deleted
100644 → 0
View file @
0bcbe3c8
import
tweepy
# === Basic Authentication ===
#
# *Note: Basic Authentication is deprecated and no longer supported on Twitter.
# It is still provided for use in services like Status.net which still suppports it.*
#
# This mode of authentication requires the user provide their username and plain text password.
# These credentials will then be provided for each request to the API for authentication.
# You would normally fetch this in your application
# by asking the user or loading from some dark place.
username
=
""
password
=
""
# Create an authentication handler passing it the username and password.
# We will use this object later on when creating our API object.
auth
=
tweepy
.
auth
.
BasicAuthHandler
(
username
,
password
)
# Create the API object providing it the authentication handler to use.
# Each request will then be authenticated using this handler.
api
=
tweepy
.
API
(
auth
)
api
.
update_status
(
'Updating using basic authentication via Tweepy!'
)
tweepy/__init__.py
View file @
f30bf332
...
...
@@ -13,7 +13,7 @@ from tweepy.models import Status, User, DirectMessage, Friendship, SavedSearch,
from
tweepy.error
import
TweepError
from
tweepy.api
import
API
from
tweepy.cache
import
Cache
,
MemoryCache
,
FileCache
from
tweepy.auth
import
BasicAuthHandler
,
OAuthHandler
from
tweepy.auth
import
OAuthHandler
from
tweepy.streaming
import
Stream
,
StreamListener
from
tweepy.cursor
import
Cursor
...
...
tweepy/auth.py
View file @
f30bf332
...
...
@@ -21,19 +21,6 @@ class AuthHandler(object):
raise
NotImplementedError
class
BasicAuthHandler
(
AuthHandler
):
def
__init__
(
self
,
username
,
password
):
self
.
username
=
username
self
.
_b64up
=
base64
.
b64encode
(
'%s:%s'
%
(
username
,
password
))
def
apply_auth
(
self
,
url
,
method
,
headers
,
parameters
):
headers
[
'Authorization'
]
=
'Basic %s'
%
self
.
_b64up
def
get_username
(
self
):
return
self
.
username
class
OAuthHandler
(
AuthHandler
):
"""OAuth authentication handler"""
...
...
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