【发布时间】:2014-09-07 09:17:28
【问题描述】:
我试图从我可以通过 API 访问的 netatmo 站获取数据。我在 R 中使用的以下代码。
myapp <- oauth_app("my_netatmo",key="my_netatmo_client_id",secret="my_netatmo_client_secret")
ep <- oauth_endpoint(authorize = "http://api.netatmo.net/oauth2/authorize",access = "http://api.netatmo.net/oauth2/token")
sig_tok <- oauth2.0_token(ep,myapp, scope="read_station")
#after that I get redirected to my browser to log in and after that sig_tok contains an access token
sig <- config(token = sig_tok)
html_get<-GET("http://api.netatmo.net/api/devicelist",sig)
html_get 包含以下内容:
html_get
Response [http://api.netatmo.net/api/devicelist]
Status: 400
Content-type: application/json; charset=utf-8
{"error":{"code":1,"message":"Access token is missing"}}
我做错了什么,因为“sig”似乎包含一个令牌:
sig$token$credentials$access_token
[1] "5**********************f|3**********************a"
有两个标记还是我错了(因为中间有“|”)?
【问题讨论】:
标签: r api oauth access-token