我正在尝试从贝宝的授权 api 获取访问令牌。当我向 api 发出 post 请求时,我得到UNSUPPORTED_MEDIA_TYPE415 响应。
下面是我使用的片段。
const auth = await fetch(PAYPAL_OAUTH_API, {
method: 'post',
headers: {
'Content-Type': 'application/json',
'Authorization': `Basic ${ basicAuth }`
},
body: JSON.stringify({"grant_type": "client_credentials"})
});
Run Code Online (Sandbox Code Playgroud)
我已通过设置Content-Type为application/x-www-form-urlencoded.
我的猜测是贝宝只接受application/x-www-form-urlencoded授权 api。
我遇到了同样的问题,解决方案如下(使用 Postman):
Token到Authorization,类型为 Bearer-TokenContent-Type: application/json在标题中选择RAW如的身体,并在TEXT下拉列表中,选择JSON( application/JSON)第 4 步和第 5 步是解决错误的方法,您必须发送原始 json 对象。
| 归档时间: |
|
| 查看次数: |
3396 次 |
| 最近记录: |