Question: Is there a way to avoid having to manually enter a PIN when doing an OAuth handshake?
Context: When making a ROAuth handshake, I am asked to enter a PIN which I obtain by following a link:
rm(list=ls())
library("twitteR")
library("ROAuth")
Credentials <- OAuthFactory$new(
consumerKey = "...",
consumerSecret = "...",
oauthKey = "...",
oauthSecret = "...",
requestURL = "https://api.twitter.com/oauth/request_token",
authURL = "https://api.twitter.com/oauth/authorize",
accessURL = "https://api.twitter.com/oauth/access_token")
Credentials$handshake(cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl"))
Which outputs:
Credentials$handshake(cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl")) To enable the connection, please direct your web browser to: https://api.twitter.com/oauth/authorize?oauth_token=... When complete, record the PIN given to you and provide it here:
And I enter a PIN.
I would like to avoid this step because everytime I run the script in a new R session I have to manually open the browser to retrieve the PIN. I am the only person using this script.
After you perform the handshake you can save the object to a file ...
At a later date you can use load() to pull the file in and use your original Credentials object.