【发布时间】:2021-11-26 03:10:15
【问题描述】:
我正在使用 Vue 应用程序并使用 Axios 进行 api 使用。 我正在尝试使用来自 AWS 的 oauth api 来获取令牌并在其他 api 中使用它。 但是,我在控制台中只收到 400。该 api 在 Postman 中运行良好,所以我真的不知道问题可能是什么。我在这里查看了其他一些问题,但没有任何效果。 这是我的代码。
auth_api() {
axios
.post(
'https://myawssite.amazoncognito.com/oauth2/token',
{'grant_type':'client_credentials'},
{headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': 'Basic 123qwe=='
}}
)
.then(response => (this.token = response))
}
【问题讨论】:
-
您是否考虑过为此使用 AWS Amplify 库?它有很多工具,也许其中之一可以帮助您处理逻辑
-
嗨@TristanMüller 感谢您的回复!我去看看。
标签: javascript amazon-web-services vuejs2 axios