From 801c81e109f60df40a2a8594933f152949ea96a3 Mon Sep 17 00:00:00 2001 From: Josh Roesslein Date: Tue, 10 May 2011 23:15:25 -0500 Subject: [PATCH] Add Basic Authentication example. --- examples/basic_auth.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 examples/basic_auth.py diff --git a/examples/basic_auth.py b/examples/basic_auth.py new file mode 100644 index 0000000..990a24e --- /dev/null +++ b/examples/basic_auth.py @@ -0,0 +1,25 @@ +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!') + -- 2.25.1