这是请求
POST /oauth/token HTTP/1.1
Host: api.quizlet.com
Authorization: Basic N0pIMzhUMjd6TTpOM3JYd3l2TU5OWlNGQWNBd0ozZ3lH
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
grant_type=authorization_code&code=GENERATED_CODE
这是响应
{
"access_token": "46a54395f3d1108feca56c7f6ca8dd3d",
"token_type": "bearer",
"expires_in": 3600,
"scope": "read",
"user_id": "ryu_nishida"
}
这是我的代码
Unirest.post "http://api.quizlet.com/oauth/token",
headers:{ Authorization: "Basic
N0pIMzhUMjd6TTpOM3JYd3l2TU5OWlNGQWNBd0ozZ3lH"},
grant_type=authorization_code&code=GENERATED_CODE
我的代码没有任何响应,但没有任何错误。
您需要将响应对象保存在变量中,
response = Unirest.post("http://api.quizlet.com/oauth/token",
auth:{:user=>"username", :password=>"password"})
然后您有获取详细信息的方法
response.code # Status code
response.headers # Response headers
response.body # Parsed body
response.raw_body # Unparsed body
阅读docs