我有一个 Google Docs 电子表格,我想用它来更新 Trello 中引用的卡片。我在 oauth 和通过他们的 HTTP API 提取数据方面取得了一些成功,但我坚持以下几点:
1) Trello 的 code.js 似乎需要一个 window 对象,而 Google Doc 脚本没有提供该对象。所以,我坚持使用他们的 HTTP API。
2) 通过 OAuth 进行身份验证有效,但只授予我读取权限。我无法使用我能够获得的令牌更新卡片。
function test() {
var oauthConfig = UrlFetchApp.addOAuthService("trello");
oauthConfig.setAccessTokenUrl("https://trello.com/1/OAuthGetAccessToken");
oauthConfig.setRequestTokenUrl("https://trello.com/1/OAuthGetRequestToken");
oauthConfig.setAuthorizationUrl("https://trello.com/1/authorize?key=" + consumerKey + "&name=trello&expiration=never&response_type=token&scope=read,write");
//oauthConfig.setAuthorizationUrl("https://trello.com/1/OAuthAuthorizeToken"); <-- this only gives read access. Cannot POST
oauthConfig.setConsumerKey(consumerKey);
oauthConfig.setConsumerSecret(consumerSecret);
var url = 'https://trello.com/1/cards/yOqEgvzb/actions/comments&text=Testing...';
var postOptions = {"method" : "post",
"oAuthServiceName": "trello",
"oAuthUseToken": "always"};
var response = UrlFetchApp.fetch(url, postOptions); // "Request failed for returned code 404. Truncated server response: Cannot POST"
Logger.log(response.getContentText());
}
我发现了一些相关的问题,但没有直接的答案:
如何使用 Trello API 获取用于写入的永久用户令牌?
Trello API:如何从 Google Apps 脚本 (GAS) 发布卡片
Google 应用程序脚本 oauth connect 不适用于 trello
非常感谢您的任何建议。