【发布时间】:2020-01-29 17:10:52
【问题描述】:
我正在尝试从 Polar Accesslink API 读取一些数据。我已经阅读了 Oauth2.0 的文档和示例(我对 Python 不太熟悉)以及 httr 示例/演示:
https://www.polar.com/accesslink-api/#polar-accesslink-api
https://github.com/polarofficial/accesslink-example-python
这是我的代码:
library(httr)
client_id <- rstudioapi::askForPassword()
client_secret <- rstudioapi::askForPassword()
# redirect_uri determined in registration to http://localhost:1410/
app <- oauth_app(appname = "polar_app",
key = client_id,
secret = client_secret)
endpoint <- oauth_endpoint(
request = NULL,
authorize = "https://flow.polar.com/oauth2/authorization",
access = "https://polarremote.com/v2/oauth2/token")
token <- oauth2.0_token(endpoint = endpoint,
app = app,
scope = "accesslink.read_all", # tested also without scope
use_basic_auth = T # tested both T and F
)
代码的最后一部分(令牌)产生以下错误:
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.
它使用 url localhost:1410/?state={STATE}&code={CODE} 打开浏览器并显示:
“身份验证完成。请关闭此页面并返回R。”
根据 API 文档和 github Python 示例,我无法确定是否需要在 oauth2.0_token 中为 user_params 或 query_authorize_extra 设置一些值。
【问题讨论】: