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

如何获取Zoho CRM沙箱环境的Client ID、Client Secret及Refresh Token?

获取Zoho CRM沙箱环境凭证步骤

1. 创建沙箱专用客户端应用

  • 登录Zoho开发者控制台,切换至沙箱环境(与生产环境控制台入口独立,请勿混用)
  • 选择创建「Server-based Applications」(适配Node.js后端接口场景)或使用「Self Client」模式
  • 填写应用基础信息(名称、回调URL等,沙箱回调URL可与生产环境一致或使用测试地址)
  • 应用创建完成后,即可直接获取Client ID和Client Secret

2. 生成沙箱环境Refresh Token

方式一:Self Client快速生成

  • 在Self Client页面输入所需权限范围,例如ZohoCRM.modules.ALL,ZohoCRM.settings.ALL(按需调整)
  • 选择「持久令牌」作为有效期(除非手动撤销,否则不会过期)
  • 点击「创建」生成授权码,再通过以下Node.js代码调用令牌接口获取Refresh Token:
const axios = require('axios');

async function fetchRefreshToken() {
  const res = await axios.post('https://accounts.zoho.eu/oauth/v2/token', {
    code: '你的授权码',
    client_id: '沙箱Client ID',
    client_secret: '沙箱Client Secret',
    redirect_uri: '你的回调URL',
    grant_type: 'authorization_code'
  });
  console.log('Refresh Token:', res.data.refresh_token);
}

fetchRefreshToken();

注意:需根据沙箱所在地区调整域名,美国区为zoho.com,欧盟区为zoho.eu。

方式二:标准OAuth授权流程(适合正式应用)

  • 构造授权URL,替换对应参数:
    https://accounts.zoho.eu/oauth/v2/auth?response_type=code&client_id=沙箱Client ID&scope=ZohoCRM.modules.ALL&redirect_uri=你的回调URL&access_type=offline
  • 在浏览器打开该URL,使用沙箱账号登录并完成授权
  • 授权成功后,回调URL会携带授权码,再通过上述令牌接口获取Refresh Token

3. 验证凭证有效性

  • 使用沙箱Refresh Token调用API测试,例如获取线索列表:
async function testSandboxAPI() {
  // 获取Access Token
  const tokenRes = await axios.post('https://accounts.zoho.eu/oauth/v2/token', {
    refresh_token: '沙箱Refresh Token',
    client_id: '沙箱Client ID',
    client_secret: '沙箱Client Secret',
    grant_type: 'refresh_token'
  });
  const accessToken = tokenRes.data.access_token;

  // 调用沙箱CRM API(替换为你的沙箱专属域名)
  const crmRes = await axios.get('https://crm.zoho.eu/sandbox/xxxxxx/api/v2/Leads', {
    headers: { Authorization: `Zoho-oauthtoken ${accessToken}` }
  });
  console.log('沙箱API测试结果:', crmRes.data);
}

testSandboxAPI();

沙箱CRM API域名格式为https://crm.zoho.xx/sandbox/[沙箱ID]/api/v2/,可在沙箱CRM设置中查看专属域名。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.11 21:43:14