From a8375a85aa36695a491d1d7669528cf1deb008b9 Mon Sep 17 00:00:00 2001 From: Harmon Date: Sat, 30 Oct 2021 10:41:43 -0500 Subject: [PATCH] Update and improve oauth.py example --- examples/oauth.py | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/examples/oauth.py b/examples/oauth.py index e6c3b1e..c737d5b 100644 --- a/examples/oauth.py +++ b/examples/oauth.py @@ -1,31 +1,25 @@ import tweepy -# == OAuth Authentication == -# -# This mode of authentication is the new preferred way -# of authenticating with Twitter. +# Your app's API/consumer key and secret can be found under the Consumer Keys +# section of the Keys and Tokens tab of your app, under the +# Twitter Developer Portal Projects & Apps page at +# https://developer.twitter.com/en/portal/projects-and-apps +consumer_key = "" +consumer_secret = "" -# The consumer keys can be found on your application's Details -# page located at https://dev.twitter.com/apps (under "OAuth settings") -consumer_key="" -consumer_secret="" - -# The access tokens can be found on your applications's Details -# page located at https://dev.twitter.com/apps (located -# under "Your access token") -access_token="" -access_token_secret="" +# Your account's (the app owner's account's) access token and secret for your +# app can be found under the Authentication Tokens section of the +# Keys and Tokens tab of your app, under the +# Twitter Developer Portal Projects & Apps page at +# https://developer.twitter.com/en/portal/projects-and-apps +access_token = "" +access_token_secret = "" auth = tweepy.OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_token, access_token_secret) api = tweepy.API(auth) -# If the authentication was successful, you should -# see the name of the account print out -print(api.verify_credentials().name) - -# If the application settings are set for "Read and Write" then -# this line should tweet out the message to your account's -# timeline. The "Read and Write" setting is on https://dev.twitter.com/apps -api.update_status(status='Updating using OAuth authentication via Tweepy!') +# If the authentication was successful, this should print the +# screen name / username of the account +print(api.verify_credentials().screen_name) -- 2.25.1