Authorization methods
Users can create their personal access token in two different ways. Each method is outlined below.
1. Browser-based authentication
- Authentication via web browser requires the
httpuv
package to be installed.
- Click the tab labeled
Keys and Access Tokens
to retrieve your keys.

- In the
Keys and Access Tokens
tab, locate the values Consumer Key
(aka “API Key”) and Consumer Secret
(aka “API Secret”).

- Copy and paste the two keys (along with the name of your app) into an R script file and pass them along to
create_token()
.
A browser window should pop up. Click to approve (must be signed into twitter.com) and return to R.
The create_token()
function should automatically save your token as an environment variable for you. To make sure it worked, compare the created token object to the object returned by get_token()
2. Access token/secret method
- Click the tab labeled
Keys and Access Tokens
to retrieve your keys.

- In the
Keys and Access Tokens
tab, locate and copy/paste values Consumer Key
(aka “API Key”) and Consumer Secret
(aka “API Secret”) into an R script.

- In the
Keys and Access Tokens
tab, scroll down to Token Actions
and click Create my access token
.

- That should generate two access keys
Access Token
and Access Token Secret

- Locate and copy/paste the
Consumer Key
(aka “API Key”), Consumer Secret
(aka “API Secret”), Access Token
, and Access Token Secret
values and pass them along to create_token()
, storing the output as a token
object.
- The
create_token()
function should automatically save your token as an environment variable for you. To make sure it worked, compare the created token object to the object returned by get_token()
That’s it!