Authentication Tutorial — tweepy v1.4 documentation

Authentication Tutorial

Introduction

Tweepy supports both basic and oauth authentication. Authentication is handled by tweepy.AuthHandler classes with two implementations provided:

OAuthHandler

BasicAuthHandler

Basic Authentication

Basic authentication uses the user’s Twitter username and password for authenticating with the API. You must query the user for these two pieces of infomation before we can authenticate.

Now first we must create an instance of the BasicAuthHandler and pass into it the username and password:

auth = tweepy.BasicAuthHandler(username, password)

Next we need to create our API instance which will be used for executing requests to the Twitter API:

api = tweepy.API(auth)

We are now ready to make API calls that are authenticated! Here is a quick example posting a new tweet to the authenticated user’s account:

api.update_status(‘hello from tweepy!’)

OAuth Authentication

vía Authentication Tutorial — tweepy v1.4 documentation.

Anuncios

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s

A %d blogueros les gusta esto: