我注意到许多关于Twitter API身份验证问题的主题,但显然没有人与我的问题相关。只要我尝试进行身份验证,在我被要求输入PIN码后,系统就会抛出一个错误(“未经授权”)。发生这种情况之前我可以输入PIN码。Twitter OAuth未授权错误
的代码是:
library("twitteR")
library("RCurl")
library("ROAuth")
# Set SSL certs globally
options(RCurlOptions = list(cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl")))
Credentials <- OAuthFactory$new(
consumerKey = "XX",
consumerSecret = "XX",
oauthKey = "XX",
oauthSecret = "XX",
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"))
而且结果是:
To enable the connection, please direct your web browser to:
https://api.twitter.com/oauth/authorize?oauth_token=XX
When complete, record the PIN given to you and provide it here:
Error: Unauthorized
正如上面提到的,这种情况发生之前,其实我可以输入个人识别码。我在RStudio中运行脚本,但在传统的R GUI上运行并没有任何改变。我正在运行R版本3.0.1。
Post Scriptum 我尝试了不同版本的代码,例如this one,但我得到了完全相同的错误。