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

PayPal REST API /v2/scim/Users接口请求无限挂起问题排查

解决PayPal SCIM接口请求挂起及客户邮箱获取问题

1. 处理请求无限挂起的问题

你的Node.js代码中,fetch返回的是Promise对象,若未通过await或.then()处理,代码会直接跳过执行逻辑,表现为“无限挂起”。修改后的代码如下:

var fetch = require('node-fetch');

async function getPayPalUser() {
  try {
    const response = await fetch('https://api-m.sandbox.paypal.com/v2/scim/Users/7XRNGHV24HABC', {
      headers: {
        'Content-Type': 'application/scim+json',
        'Authorization': 'Bearer <Access-Token>'
      }
    });
    const data = await response.json();
    console.log(data);
  } catch (err) {
    console.error(err);
  }
}

getPayPalUser();

Postman中出现挂起时,检查是否开启代理、网络环境能否正常连接PayPal沙箱服务器,也可尝试切换到Postman原生网络模式。

2. 访问令牌的权限要求

能调用交易查询接口的令牌,不一定具备SCIM接口的访问权限。SCIM接口要求令牌包含user:read或user:write的scope,而交易查询通常仅需transaction:read类权限,你需要重新生成包含对应SCIM权限的访问令牌。

3. 关于application/scim+json内容类型

这是PayPal SCIM接口要求的标准媒体类型,符合SCIM协议定义,无需修改,保持该设置即可。

4. 获取客户邮箱的更简便方式

若仅需获取客户邮箱,无需使用SCIM接口,直接调用/v2/customers/{customer-id}接口更高效,权限要求更低:

async function getCustomerEmail() {
  try {
    const response = await fetch('https://api-m.sandbox.paypal.com/v2/customers/7XRNGHV24HABC', {
      headers: {
        'Authorization': 'Bearer <Access-Token>'
      }
    });
    const customerData = await response.json();
    console.log('客户邮箱:', customerData.email);
  } catch (err) {
    console.error(err);
  }
}

getCustomerEmail();

该接口仅需customer:read的scope,生成令牌时包含此权限即可。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.22 07:14:49