gpt4 book ai didi

google-apps-script - 如何从 Google 文档脚本授权和发布/更新 Trello 卡

转载 作者:行者123 更新时间:2023-12-04 04:36:56 24 4
gpt4 key购买 nike

我有一个 Google Docs 电子表格,我想用它来更新 Trello 中的引用卡片。我在 oauth 和通过他们的 HTTP API 提取数据方面取得了一些成功,但我坚持以下几点:

1) 似乎 Trello 的 code.js 需要一个 window 对象,而 Google Doc 脚本没有提供。所以,我坚持使用他们的 HTTP API。

2) 通过 OAuth 进行身份验证有效,但只给我读取权限。我无法使用我能够获得的 token 更新卡片。

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: vote on a card

Trello API: How to POST a Card from Google Apps Script (GAS)

Google apps script oauth connect doesn't work with trello

非常感谢您提供任何建议。

最佳答案

为了获得写入权限,您需要更改授权 url。
这个例子对我有用

  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/OAuthAuthorizeToken?scope=read,write");

关于google-apps-script - 如何从 Google 文档脚本授权和发布/更新 Trello 卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19597327/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com