You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Access Token获取Pinterest登录用户的详细信息

Pinterest API v5 获取用户信息解决方案

你的代码核心错误是Authorization请求头格式不符合Pinterest API要求,你错误将权限标识填入了认证头,正确规则和修改方案如下:

  • Pinterest v5 API使用标准OAuth2 Bearer认证格式,认证头的格式为Bearer ${你的access_token},不需要在头中填写权限scope
  • 仅需要保证你之前获取access_token的授权流程中,已经向用户申请了user_accounts:read权限即可

修正后的可运行代码如下:

const { access_token } = responseData;
let userAccountDataUrl = `https://api.pinterest.com/v5/user_account`;
axios.get(userAccountDataUrl, {
    headers: {
        'Authorization': `Bearer ${access_token}`
    }
}).then((userAccountResponse) => {
    const userData = userAccountResponse.data;
    console.log(`FetchedUserAccount=${JSON.stringify(userData, null, 2)}`);
}).catch((e) => {
    console.log(`Error fetching user account due to ${JSON.stringify(e.response.data)}`);
});

如果修改后仍然报错,可按照以下步骤排查:

  • 打印access_token确认值有效,未空或者被截断
  • 确认该access_token未过期,Pinterest access_token默认有效期为30天,过期需要重新走授权流程获取
  • 确认你的开发者账号后台应用已经开通了v5 API的调用权限,无调用限制

内容的提问来源于stack exchange,提问作者ololo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.04 05:18:04