[英]Connecting to LinkedIn via ouath and R
已使用R成功連接到Twitter,並嘗試利用該代碼連接到LinkedIn,但不能完全使其正常工作。
我認為代碼已經結束,但是最后一步會返回錯誤。
目前,我能夠讓LinkedIn在握手后立即返回令牌,但是當我在瀏覽器中查詢令牌時,我從linkingIn收到一條錯誤消息,提示必須提供client_id。
https://www.linkedin.com/uas/oauth2/authorization?oauth_token= <...>
下面是用於創建OAuth文件的R代碼,其中已刪除了LinkedIn提供的密鑰。
rm(list=ls())
library(ROAuth)
reqURL <- "https://api.linkedin.com/uas/oauth/requestToken"
accessURL <- "https://api.linkedin.com/uas/oauth2/accessToken"
authURL <- "https://www.linkedin.com/uas/oauth2/authorization"
consumerKey <- "<...>"
consumerSecret <- "<...>"
#oAuthKey <- "<...>"
#oAuthSecret <- "<...>"
linkedInCred <- OAuthFactory$new(consumerKey=consumerKey,
consumerSecret=consumerSecret,
requestURL=reqURL,
accessURL=accessURL,
authURL=authURL)
linkedInCred$handshake()
credentials$OAuthRequest(testURL, "GET")
save(linkedInCred, file="credentials.RData")
請改用httr
。 Hadley的軟件包中有一個示例: https : //github.com/hadley/httr/blob/master/demo/oauth2-linkedin.r
這是例子
library("httr")
myapp <- oauth_app(appname = "scottsapp", key = "<key>", secret = "<secret>")
TokenLinkedIn <- R6::R6Class("TokenLinkedIn", inherit = Token2.0, list(
sign = function(method, url) {
url <- parse_url(url)
url$query$oauth2_access_token <- self$credentials$access_token
list(url = build_url(url), config = config())
}
))
token <- TokenLinkedIn$new(endpoint = oauth_endpoints("linkedin"), app = myapp)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.