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

使用个人ClickUp令牌在Google Apps Script中调用ClickUp API时遭遇OAUTH_017授权错误的求助

Fixing ClickUp API Authorization Error in Google Apps Script

Let me break down why you're hitting that ECODE=OAUTH_017 error and how to fix it quickly.

The core issue here is how you're passing the authorization header in your UrlFetchApp.fetch() call. In Google Apps Script, request headers need to be nested under a headers object within the options parameter—you can't just put them as top-level keys. Your current code is trying to set Authorization directly in the options, which means ClickUp's API never actually receives the header.

Corrected Code

function getClickupTeam() { 
  // Ensure your clickupUrl ends with a slash, e.g., "https://api.clickup.com/api/v2/"
  let response = UrlFetchApp.fetch(clickupUrl + "team", { 
    method: "GET", 
    headers: {
      "Authorization": clickupToken // Now properly nested in the headers object
    },
    muteHttpExceptions: true 
  }); 
  Logger.log(response.getContentText()); // Log raw response text for easier debugging
  let json = JSON.parse(response.getContentText()); 
  Logger.log(json); 
}

Additional Checks to Verify

  • Token Format: Double-check that your clickupToken starts with pk_ (this is the required prefix for ClickUp personal tokens). Using a workspace token or a token with an incorrect prefix will cause authorization failures.
  • API URL Validity: Confirm clickupUrl is set to the correct base URL: https://api.clickup.com/api/v2/ (don't skip the trailing slash—without it, your request will target an invalid endpoint like https://api.clickup.com/api/v2team).
  • Script Permissions: When running the script for the first time, make sure you grant it permission to access external services (UrlFetchApp requires this authorization from your Google account).

If you still run into issues after these fixes, try logging the full options object before the fetch call with Logger.log(JSON.stringify(options)) to confirm the Authorization header is being sent correctly.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.29 04:57:29