Twitter authentication setup: Difference between revisions

From CommunityData
No edit summary
mNo edit summary
 
(11 intermediate revisions by 2 users not shown)
Line 3: Line 3:
Things you will need before you start:
Things you will need before you start:


* '''A Twitter account.''' If your Twitter profile doesn't have your current mobile number associated with it, you will need to add your mobile number in order to create your new app as part of the process.
== Get a Twitter Account and Link It to a Mobile Phone ==
'''A Twitter account.''' To collect tweets from Twitter, you need a Twitter account. If your Twitter profile doesn't have your current mobile number associated with it, you will need to add your mobile number in order to create your new app as part of the process.


== Apply to be a Twitter Developer ==
To collect tweets, you need to be approved by Twitter to be a developer.
Follow each of these steps:
Follow each of these steps:


'''1.''' Go to the Twitter development homepage: https://dev.twitter.com/   
'''1.''' Go to the Twitter development homepage: https://developer.twitter.com/   
 
'''2.''' If you're not already signed in to Twitter, click on '''Sign In''' in the top right corner of the page. You can sign in with your normal Twitter account. (It may take you to your Twitter home page when you sign in. If so, return to https://developer.twitter.com/ once you're logged on.)
 
'''3.''' Click on the [https://developer.twitter.com/en/apply-for-access "Apply" link] (https://developer.twitter.com/en/apply-for-access). The link should be located in the top right of the page beside "Apps" and your Twitter icon.
 
'''4''' Click "Apply for a Developer Account" in the middle of the page.
 
'''5''' The next page asks "What is your primary reason for using Twitter developer tools?" and gives you a lot of options. ''Click Student'', which is in the third column.
 
'''6''' On the next page, under "what would you like us to call you", put "CDSW_student".
 
What you are signing up for is an Individual Developer Account (as opposed to Team Developer Account).
 
[[File:Capture20200126.PNG|400px]]
 
'''7''' Next, Twitter will ask you about your plans. ''Please follow these instructions carefully to make sure Twitter approves your application.''
 
In the field "In your words":
 
    I am taking a Community Data Science course at the University of Washington. My instructors are Mako Hill (makohill@uw.com), Tommy Guy (guyrt@uw.ed), and Dharma Dailey (ddailey@uw.edu). You can find our workshop details at https://wiki.communitydata.science/Community_Data_Science_Workshops_(Winter_2020).
 
Under "The Specifics" check yes for "Are you planning to analyze Twitter data" and enter the following text:
 
    We are learning to download Twitter data and do basic analysis. For instance, we will try to determine whether an earthquake has happened recently or whether there is a basketball game going on.
 
Uncheck the sliders for "Will your app use Tweet, Retweet, like, follow, or Direct Message functionality?" and all other options.
 
[[File:Capture20200126_1.PNG|400px]]
 
[[File:Capture20200126_2.PNG|400px]]
 
 
'''8''' Click "next" in the lower right then click "Looks good" on the review page. Finally, accept the terms of service and click "Submit Application" on the next page.
 
 
 
'''9''' Twitter will send an email to the account you used. Click "Confirm your email" in that email to finish setup.
 
 
 
'''If you have any trouble with the steps before this, email us before Saturday.''' If you have trouble on the next steps, we'll be able to help you on Saturday.
 
 
== Confirm your developer email address  ==
 
'''10''' When you confirm in the email, you will arrive at https://developer.twitter.com/en/account/get-started. On that page, click "Create an app". This will take you to https://developer.twitter.com/en/apps


'''2.''' If you're not already signed in to Twitter, click on '''Sign In''' in the top right corner of the page. You can sign in with your normal Twitter account. (It may take you to your Twitter home page when you sign in. If so, return to https://dev.twitter.com/ once you're logged on.)
'''11''' Click "Create an app", which takes you to https://developer.twitter.com/en/apps/create. You'll need to fill in a few details about your app.


'''3.''' Click on the [https://dev.twitter.com/apps "Manage Your Apps" link] (https://apps.twitter.com/). The link should be located at the bottom of the page under the heading, "Tools." This will take you to a page that says "You don't currently have any Twitter Apps" with a button underneath that says "Create New App". Click the "Create New App" button.
App name: "CDSW Sample <Your_First_and_Last_Name>"


'''4.''' The next page will ask for application details. The first three are required so you will need to create a ''Name'', ''Description'', and ''Website URL''. You can choose whatever you want for these fields but keep in mind that the name ''can not'' contain the word "Twitter". Also keep in mind that the name needs to be ''unique'' in the world. The name itself does not matter. You should leave the "Callback URL" blank. You will also need to click the checkbox to agree to the Twitter Developer Agreement.
Application Description: "Sample application for the CDSW workshop."


:Name: CDSW Test Application for '''<YOUR NAME>'''
Website: "https://www.example.com"
:Description: CDSW Test Application
:Website: http://www.example.com/


Below this, you will see a long "Developer Agreement". Look through this and, if you agree, click the checkbox marked "Yes, I agree." (If you haven't included your mobile number in your profile information, you may be asked to do this before you can continue with creating an app).
Callback URLs: "https://www.example.com"


'''6.''' You should now see page a page that says "Application Management" on the top and the name of your app (probably "''CDSW Test Application for <YOUR NAME>''") right below the blue bar.
Leave "Enable Sign in with Twitter" unchecked.


Right below that there are four tabs that say::
The next few fields are not needed, but scroll to the bottom to find "Tell us how this app will be used".


:Details
Tell us how this app will be used: "Learning data science with python in the Community Data Science workshop. This app is for testing purposes only."
:Settings
:Keys and Access Tokens
:Permissions


'''7.''' Click on the Keys and Access Tokens tab.
Finally, click create, and click create again in the modal window.


: You should now see a list of "Application settings". The first two here are the most important and you will need to copy and paste these into a file. The first is the Consumer Key (API key). The second is the Consumer Secret (API secret). Both of them should be long strings of garbage looking letters and numbers. These are the keys that will let your program know that it's approved to grab data from Twitter.
*Almost there!!*


'''8.''' Now, at the bottom of  the page you should see a section marked "Your Access Token" that says, "You haven't authorized this application for your own account yet." Below that there is a button that says "Create my access token". Click on that button. Once you press it there will be a yellow 'Status' box at the top. It will give you a link you can click to refresh. Wait a minute or two and click it until you see information, below including lines that give you your "Access token" and your "Access token secret". Copy these two pieces of information.
== Generate and copy your individual, private, unique Twitter developer credentials ==
'''12''' In the next step, you will access Twitter credentials, which will let you authenticate with Twitter in python.


'''9.''' You should have four long strings of letters and numbers taken from this page now:
You need unique, private credentials to collect tweets. You will be pasting these credentials into your Python code. Be sure if you share your Python code, you ***do not** share your unique developer credentials.


* Consumer Key (API key)
You should be at a page that looks like:
* Consumer Secret (API secret)
* Access token
* Access token secret


You will need all of these in order to have your Twitter application work.
[[File:Capture20200126_2.PNG|400px]]


Copy and paste each of these into a document or text file so that you have them all and know which ones are which. Bring this information to the Saturday session.
Click the "Keys and Tokens" tab. You will see a box called "Consumer API keys" with two long strings labeled "API key" and "API secret key". You should copy and paste those into a text file on your desktop.


''Keep this material secret.'' Your access token and access token secret will allow anybody who has it to post to Twitter as you and to control your account. It is equivalent to your Twitter username and password so please be as careful with it as you would be with your Twitter password!
Finally, click "Generate" which will open a modal with two new strings called "Access Token" and "Access Token Secret". Copy these two keys to the same file and close the modal.
 
You will need all four of these strings in order to have your Twitter application work.
 
'''Keep this material secret.''' Your access token and access token secret will allow anybody who has it to post to Twitter as you and to control your account. It is equivalent to your Twitter username and password so please be as careful with it as you would be with your Twitter password!


== Other documentation ==
== Other documentation ==
Explore how Tweets are structured *[https://developer.twitter.com/en/docs/tweets/data-dictionary/overview/tweet-object Twitter Data Dictionary Tweet Objects]
In this workshop, we'll be working with TWO different Twitter APIs, "Standard Search" and "Realtime."
More about the using the Twitter Search API :
* [https://developer.twitter.com/en/docs/tweets/search/overview Official Twitter info on the Search API]
For this workshop, we'll be working with the "Standard Search", the most limited of Twitter Search API options
* [https://developer.twitter.com/en/docs/tweets/search/overview/standard Twitter "Standard Search"]
This page has some helpful intel about modifying Standard Search parameters (including sample request and response):
* [https://developer.twitter.com/en/docs/tweets/search/api-reference/get-search-tweets Getting search tweets.]
Using the Twitter Realtime API :
* [https://developer.twitter.com/en/docs/tweets/filter-realtime/overview Official Documentation Overview of the Realtime API]


* [https://dev.twitter.com/docs/auth/tokens-devtwittercom Official documentation on how to get Tokens from dev.twitter.com]
More about the developer credentials you just generated:
* [https://developer.twitter.com/en/docs/basics/getting-started Official documentation on how to get Tokens from developer.twitter.com]


[[Category:CDSW]]
[[Category:CDSW]]

Latest revision as of 19:48, 29 January 2020

Things you will need before you start:

Get a Twitter Account and Link It to a Mobile Phone[edit]

A Twitter account. To collect tweets from Twitter, you need a Twitter account. If your Twitter profile doesn't have your current mobile number associated with it, you will need to add your mobile number in order to create your new app as part of the process.


Apply to be a Twitter Developer[edit]

To collect tweets, you need to be approved by Twitter to be a developer. Follow each of these steps:

1. Go to the Twitter development homepage: https://developer.twitter.com/

2. If you're not already signed in to Twitter, click on Sign In in the top right corner of the page. You can sign in with your normal Twitter account. (It may take you to your Twitter home page when you sign in. If so, return to https://developer.twitter.com/ once you're logged on.)

3. Click on the "Apply" link (https://developer.twitter.com/en/apply-for-access). The link should be located in the top right of the page beside "Apps" and your Twitter icon.

4 Click "Apply for a Developer Account" in the middle of the page.

5 The next page asks "What is your primary reason for using Twitter developer tools?" and gives you a lot of options. Click Student, which is in the third column.

6 On the next page, under "what would you like us to call you", put "CDSW_student".

What you are signing up for is an Individual Developer Account (as opposed to Team Developer Account).

7 Next, Twitter will ask you about your plans. Please follow these instructions carefully to make sure Twitter approves your application.

In the field "In your words":

   I am taking a Community Data Science course at the University of Washington. My instructors are Mako Hill (makohill@uw.com), Tommy Guy (guyrt@uw.ed), and Dharma Dailey (ddailey@uw.edu). You can find our workshop details at https://wiki.communitydata.science/Community_Data_Science_Workshops_(Winter_2020).

Under "The Specifics" check yes for "Are you planning to analyze Twitter data" and enter the following text:

   We are learning to download Twitter data and do basic analysis. For instance, we will try to determine whether an earthquake has happened recently or whether there is a basketball game going on. 

Uncheck the sliders for "Will your app use Tweet, Retweet, like, follow, or Direct Message functionality?" and all other options.


8 Click "next" in the lower right then click "Looks good" on the review page. Finally, accept the terms of service and click "Submit Application" on the next page.


9 Twitter will send an email to the account you used. Click "Confirm your email" in that email to finish setup.


If you have any trouble with the steps before this, email us before Saturday. If you have trouble on the next steps, we'll be able to help you on Saturday.


Confirm your developer email address[edit]

10 When you confirm in the email, you will arrive at https://developer.twitter.com/en/account/get-started. On that page, click "Create an app". This will take you to https://developer.twitter.com/en/apps

11 Click "Create an app", which takes you to https://developer.twitter.com/en/apps/create. You'll need to fill in a few details about your app.

App name: "CDSW Sample <Your_First_and_Last_Name>"

Application Description: "Sample application for the CDSW workshop."

Website: "https://www.example.com"

Callback URLs: "https://www.example.com"

Leave "Enable Sign in with Twitter" unchecked.

The next few fields are not needed, but scroll to the bottom to find "Tell us how this app will be used".

Tell us how this app will be used: "Learning data science with python in the Community Data Science workshop. This app is for testing purposes only."

Finally, click create, and click create again in the modal window.

  • Almost there!!*

Generate and copy your individual, private, unique Twitter developer credentials[edit]

12 In the next step, you will access Twitter credentials, which will let you authenticate with Twitter in python.

You need unique, private credentials to collect tweets. You will be pasting these credentials into your Python code. Be sure if you share your Python code, you ***do not** share your unique developer credentials.

You should be at a page that looks like:

Click the "Keys and Tokens" tab. You will see a box called "Consumer API keys" with two long strings labeled "API key" and "API secret key". You should copy and paste those into a text file on your desktop.

Finally, click "Generate" which will open a modal with two new strings called "Access Token" and "Access Token Secret". Copy these two keys to the same file and close the modal.

You will need all four of these strings in order to have your Twitter application work.

Keep this material secret. Your access token and access token secret will allow anybody who has it to post to Twitter as you and to control your account. It is equivalent to your Twitter username and password so please be as careful with it as you would be with your Twitter password!

Other documentation[edit]

Explore how Tweets are structured *Twitter Data Dictionary Tweet Objects

In this workshop, we'll be working with TWO different Twitter APIs, "Standard Search" and "Realtime."

More about the using the Twitter Search API :

For this workshop, we'll be working with the "Standard Search", the most limited of Twitter Search API options

This page has some helpful intel about modifying Standard Search parameters (including sample request and response):

Using the Twitter Realtime API :


More about the developer credentials you just generated: