【发布时间】:2013-11-05 00:19:36
【问题描述】:
我有一个 Google 文档电子表格,我想用它来更新 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());
}
我发现了一些相关的问题,但没有直接的答案:
How to get a permanent user token for writes using the Trello API?
Trello API: How to POST a Card from Google Apps Script (GAS)
Google apps script oauth connect doesn't work with trello
非常感谢您提前提供的任何建议。
【问题讨论】:
-
您是否有理由使用 OAuth 而不是替代方案:trello.com/docs/gettingstarted/authorize.html?客户端授权听起来更像您正在寻找的。span>
-
这会给我一个弹出窗口。有关如何呈现并处理/存储令牌以供后续调用的任何示例?
标签: google-apps-script oauth trello