如果我是唯一的用户,请避免 ROAuth 握手中的 PIN 步骤? [英] Avoid The PIN step in ROAuth handshake if I'm the only user?
问题描述
问题:有没有办法避免在进行 OAuth 握手时手动输入 PIN 码?
Question: Is there a way to avoid having to manually enter a PIN when doing an OAuth handshake?
上下文:在进行 ROAuth 握手时,我被要求输入通过以下链接获得的 PIN:
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"))
输出:
Credentials$handshake(cainfo = system.file("CurlSSL", "cacert.pem",package = "RCurl")) 要启用连接,请直接访问您的网页浏览器:https://api.twitter.com/oauth/authorize?oauth_token=...完成后,记录给您的 PIN 并在此处提供:
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:
然后我输入 PIN.
我想避免这一步,因为每次我在新的 R 会话中运行脚本时,我都必须手动打开浏览器来检索 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 ...
save(Credentials, file="credentials.RData")
稍后您可以使用 load() 拉入文件并使用您的原始凭据对象.
At a later date you can use load() to pull the file in and use your original Credentials object.
这篇关于如果我是唯一的用户,请避免 ROAuth 握手中的 PIN 步骤?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!