当我尝试使用R中的httr包从Oauth获取授权令牌时,出现“缺少授权类型”错误。我尝试符合application / x-www-form-urlencoded所需的格式,但仍然错误仍然存在。有什么想法我做错了吗?
我正在尝试的代码如下:
Auth_token_url = 'https://demoserver.com/Logon/oauth/token'
require(httr)
headers = c(
`Content-Type` = 'application/x-www-form-urlencoded'
)
data = list(
`grant_type` = 'password',
`username` = 'demouser',
`password` = 'password'
)
GetToken <- httr::POST(url = Auth_token_url, httr::add_headers(.headers=headers), body=data, httr::authenticate('ClientID', 'ClientSecret') )
GetToken_text=content(GetToken, "text")
GetToken
GetToken_text
我得到的错误如下:
回复[https://demoserver.com/Logon/oauth/token]日期:2018-09-19 13:35状态:400内容类型:application / json; charset = UTF-8
大小:68 B'{“错误”:“ invalid_request”,“错误描述”:“缺少 授予类型“}'