Coder Social home page Coder Social logo

gultugaydemir / twitter_oauth1.0a Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 24 KB

Tutorial for a script that grants your Twitter app read and write access to a Twitter account.

License: Creative Commons Zero v1.0 Universal

Python 100.00%
twitter-api twitter twitter-bot twitter-oauth tweepy tweepy-api request-library oauth1a oauth1 python authorization api read-and-write

twitter_oauth1.0a's Introduction

Twitter_OAuth1.0a

A script that grants your Twitter app read and write access to a Twitter account.

Getting started

  • This implementation is designed to authorize a Twitter application with OAuth1.0a. With this script, you will be able to get read and write access to another account and control all your Twitter bots from your main developer account. You are welcomed to fill your own keys in and use the code accordingly.
  • Remember that this script only includes the OAuth1.0a implementation. It will be useful to you only if you want to use your Twitter app from a profile other than your Twitter developer account, since I wrote the script assuming that owner of both accounts is the same person. For further information about other implementations please visit Twitter Developer.

Prerequisites

  • You should have an approved Twitter developers account and provide your own API keys for your application.

  • Installation of Tweepy library is necessary. (Open command prompt and type pip install tweepy.)

Usage

  • Run get_token.py first. It will generate the authorization_url for your application.

    https://api.twitter.com/oauth/authorize?oauth_token=HHiqAQAAAAABEhX0AAABcoaQ6F8 
    
  • Please make sure you have signed in from the account that you would like to use as your bot profile before you click the link. This URL will prompt you to a page where you are asked whether you approve the authorization or not.

  • When you click the Authorize App button, a single-use pin will be generated in the same page. You should enter the pin to the console, as this will be your verifier that will be used to generate the access tokens.

  • After the app is authorized, you will have read-and-write access to the linked account. This permission level will allow you to post tweets, follow users, hide replies or update elements of a user’s profile information, so handle with care.

    • You can revoke access anytime and you can have multiple accesses to different accounts with the same application, at the same time.
  • Once you get the access_token and access_token_secret, copy and paste them to the relevant sections in account_auth.py. This is going to create the authentication and you will be able to use methods such as update_status. For other Tweepy methods, please check the API References.

Reminder

  • Unless you want to regenerate the tokens for whatever reason, do not run get_token.py again for the same account. This is only going to create new tokens and make the former ones invalid.
  • I certainly advise you to store the access tokens safe for further use so that you don’t have to ask for access and verifier pin again and again.

If you run into any errors, feel free to contact me and I'll try to help you out. Enjoy your new bot account!

twitter_oauth1.0a's People

Contributors

gultugaydemir avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.