簡體   English   中英

twitteR ROAuth握手錯誤:未生成PIN選項

[英]twitteR ROAuth handshake error: not generating the PIN option

這個問題實際上回答了與ROAuth問題有關的所有問題:

TwitteR,ROAuth和Windows:注冊確定,但證書驗證失敗

TwitteR和ROAuth之前在我的電腦上都能完美運行。 但是代碼塊不再生成PIN選項。 它彈出以下內容:

twitCred$handshake(cainfo="cacert.pem")
Error: Unauthorized

以前twitCred $ handshake(cainfo =“ cacert.pem”)定向到:

To enable the connection, please direct your web browser to: 
https://api.twitter.com/oauth/authorize?oauth_token=SevxcpCh9riO5PPrI8U8____
When complete, record the PIN given to you

我在spark rstudio服務器中嘗試了我的代碼。 然后代碼可以完美工作(生成用於輸入PIN的選項,該密碼當前未在我的PC中生成)。 代碼是:

require(twitteR)
require(ROAuth)

requestURL <- "https://api.twitter.com/oauth/request_token"
accessURL <- "https://api.twitter.com/oauth/access_token"
authURL <- "https://api.twitter.com/oauth/authorize"
consumerKey <- "______________"
consumerSecret <- "___________________"


twitCred <- OAuthFactory$new(consumerKey=consumerKey,
consumerSecret=consumerSecret, requestURL=requestURL, accessURL=accessURL,
authURL=authURL)


setwd("/home/__")
download.file(url="http://curl.haxx.se/ca/cacert.pem", destfile="cacert.pem")
twitCred$handshake(cainfo="cacert.pem")
  To enable the connection, please direct your web browser to: 
  https://api.twitter.com/oauth/authorize?oauth_token=SevxcpCh9riO5PPrI8U8____
  When complete, record the PIN given to you

任何幫助表示贊賞。

Twitter App必須具有讀取,寫入權限。 這就是讓我繞過授權錯誤的原因。 請注意以下說明:

http://dev.twitter.com上創建一個Twitter應用程序。 確保授予應用程序讀取,寫入和直接發送消息的權限。 在Twitter應用程序頁面上記下以下值:“ API密鑰”,“ API機密”,“訪問令牌”和“訪問令牌機密”。

install.packages(c(“ devtools”,“ rjson”,“ bit64”,“ httr”))確保此時重新啟動R會話

庫(devtools)install_github(“ twitteR”,用戶名=“ geoffjentry”)庫(twitteR)setup_twitter_oauth(“ API密鑰”,“ API秘密”)

API密鑰和API密碼來自上面的Twitter應用頁面。 這將引導您完成httr的OAuth身份驗證過程。 我建議您查看httr中Token的手冊頁,以獲取有關其如何處理緩存的說明。

您應該准備出發!

twitCred$handshake(cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl"))

這對我有用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM