[英]Getting access token from the PayPal API Error
// 上面定義了秘密(javascript)
PAYPAL_OAUTH_API = "https://api.sandbox.paypal.com/v1/oauth2/token/";
// 1c. Get an access token from the PayPal API
basicAuth = `${PAYPAL_CLIENT}:${PAYPAL_SECRET}`;
const token = await axios.post(
PAYPAL_OAUTH_API,
`grant_type=client_credentials`,
{
headers: {
Accept: `application/json`,
Authorization: `Basic ${basicAuth}`,
},
}
);
return token;
它給了我錯誤“請求失敗,狀態代碼為 401 我認為問題出在grant_type=client_credentials
語法中。這是將參數傳遞給 Axios 以進行發布請求的正確語法嗎?
${basicAuth}
必須是 base64 編碼,試試${btoa(basicAuth)}
curl 的 -u 標志為你做這件事
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.