How to authorize and post/update Trello card from a Google docs script

前端 未结 2 1031
走了就别回头了
走了就别回头了 2021-02-06 19:16

I have a Google Docs Spreadsheet that I\'d like to use to update referenced cards in Trello. I\'ve had some success with oauth and pulling data via their HTTP API, but am stuck

相关标签:
2条回答
  • 2021-02-06 19:46

    In order to get write access, you need to change the authorization url. This example works for me

      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");
    
    0 讨论(0)
  • 2021-02-06 19:59

    on 1) yes you cant use the library from server gas, its meant to be run from a browser. on 2), Ive done it from GAS with write access without problems. You need to use the format: https://api.trello.com/1/.../xxxx?key=yyyyyy&token=zzzzzzz&...

    and when you get the token, you need to request permanent access (no expiration) and write access, as in: https://trello.com/1/authorize?key="+key+"&name=xxxxxxx&expiration=never&response_type=token&scope=read,write"

    As in:

    function postNewCardCommentWorker(cardId, comment, key, token) {
    
      var commentEncoded=encodeURIComponent(comment);
      var url = "https://api.trello.com/1/cards/"+cardId+"/actions/comments?text="+commentEncoded+"&key="+key+"&token="+token;
      var options =
         {
           "method" : "POST"
         };
    
      UrlFetchApp.fetch(url, options);
    }
    
    0 讨论(0)
提交回复
热议问题