【发布时间】:2018-10-17 17:39:01
【问题描述】:
我正在尝试使用 VRBO / HomeAway API 访问我正在为其构建网站的单个属性的评论。我想练习使用 API,并认为如果我使用 API 进行评论,列表会自行更新。
我正在使用 Angular 构建网站,但目前我想使用 Postman 应用程序测试 API。 API的说明可以在here找到。
我正在尝试按照指示将我的令牌发布到https://ws.homeaway.com/oauth/token。但我的困惑来自标题。有人告诉我将 a 与“标准基本身份验证标头”一起使用,我认为这仅表示“授权”(这是 Postman 提供的唯一授权标头。
但是,API 说明表明标头应该是这样的:
Authorization: Basic NTVhODQ4NjItZmE0ZS0xMWU0LWEzMjItMTY5N2Y5MjVlYzdiOjg1MzBmNDZjLWZhNGUtMTFlNC1hMzIyLTE2OTdmOTI1ZWM3Yg==
我假设“基本”不是必需的。我从 API 收到带有常规 Authorization 标头的响应,所以我认为 Authorization 没问题。
现在,授权标头的值应该是:
"where the credentials are a base-64 encoded string of your client's id and secret: '<clientId>:<clientSecret>'"
所以,我想我只需要将我的 clientId 与“:”连接起来,然后是 ny secret(所有这些我已经得到了)
然而,
我只收到此错误消息:
{
"message": "Invalid authorization. Please try again or contact support.",
"errorCode": "BAD_AUTHORIZATION"
}
API 说明提到:
Note: If you do not base-64 encode the client id:secret pair, the request will fail. Additionally, the client id and secret should never be hard coded into code that is provided to end users (mobile applications, etc).
这是我必须做的事情吗?我读过标题是自动编码的。
不胜感激。
【问题讨论】: