R httr Linkedin API:错误的请求HTTP 400

问题描述

我的问题与此问题密切相关:LinkedIn API error of redirect uri from httr

这是我的代码

random.choice

当我这样做时,浏览器将打开并显示消息library(httr) clientid <- "MY-ID" secret <- "MY-SECRET" app <- oauth_app(appname = "app name",key = clientid,secret = secret) endpoint <- oauth_endpoint(base_url = "https://www.linkedin.com/uas/oauth2",authorize = "authorization",access = "accesstoken") token <- oauth2.0_token(endpoint = endpoint,app = app)

在R中,我得到这个:

Authentication complete. Please close this page and return to R.

我使用了https://www.linkedin.com/developers/上给我的应用程序提供的客户端ID和密码,并且确实将重定向URL设置为Waiting for authentication in browser... Press Esc/Ctrl + C to abort Authentication complete. Error in oauth2.0_access_token(endpoint,app,code = code,user_params = user_params,: Bad Request (HTTP 400). Failed to get an access token.

我正在使用Ubuntu 18.04,R版本3.6.3,httr版本“ 1.4.2”。

解决方法

我认为您可能缺少scope中的oauth2.0_token()参数。

您可以使用的LinkedIn范围示例为:scope = "r_organization_social"scope = "rw_organization_admin"

因此它看起来像:

token <- oauth2.0_token(endpoint = endpoint,app = app,scope = "rw_organization_admin")

这取决于您拥有多少访问权限以及您希望通过API请求哪些数据

,

我解决了更改 :token

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...