我正在尝试将我的 Alexa 技能与我通过使用通过 LWA 配置文件生成的身份验证令牌点击https://api.amazon.com/v0/catalogs端点创建的目录相关联。
这行得通,我创建了一个这样的目录:
{
associatedSkillIds: [],
createdDate: '2022-01-22T20:50:37.318Z',
id: 'amzn1.ask-catalog.cat.[REDACTED]',
lastUpdatedDate: '2022-01-22T20:50:37.318Z',
title: 'TestCatalog',
type: 'AMAZON.AudioRecording',
usage: 'AlexaTest.Catalog.AudioRecording'
}
但是,下一步,将我的 Alexa 技能与目录关联总是返回 401 https://developer.amazon.com/en-US/docs/alexa/smapi/catalog-content-upload.html#associate-catalog-with -技能
这是我尝试将技能与目录关联的功能:
async associateSkillWithCatalog() {
console.log(`Associating skill...`);
const accessToken = await this.getRefreshToken(); // makes post to https://api.amazon.com/auth/o2/token
console.log(this.alexaEndpoint + this.skillAssoc(cat.id, skillId));
const response = await axios.put(
"https://api.amazonalexa.com/v0/skills/amzn1.ask.skill.[REDACTED]/catalogs/amzn1.ask-catalog.cat.[REDACTED]",
{
headers: {
'Content-type': 'application/json',
'Authorization': `Bearer ${accessToken}`
}
}
);
return response.data;
}
总是收到此错误:请求失败,状态代码 401\n 在 createError。
为什么我会在这里收到 401 错误,尽管针对此 API 的其他请求没有失败?
谢谢!