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

前端 未结 2 1033
走了就别回头了
走了就别回头了 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: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);
    }
    

提交回复
热议问题