title: How to authorize and post/update Trello card from a Google docs script
body: <p>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 with the following:</p>
  
  <p>1) it seems Trello's code.js requires a window object, which the Google Doc script doesn't provide. So, I am stuck using their HTTP API.</p>
  
  <p>2) authenticating via OAuth works, but only gives me read access.  I cannot update cards with the token I am able to get.</p>
  
  <pre><code>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 + "&amp;name=trello&amp;expiration=never&amp;response_type=token&amp;scope=read,write");
    //oauthConfig.setAuthorizationUrl("https://trello.com/1/OAuthAuthorizeToken");  &lt;-- this only gives read access.  Cannot POST
    oauthConfig.setConsumerKey(consumerKey);
    oauthConfig.setConsumerSecret(consumerSecret);
  
    var url = 'https://trello.com/1/cards/yOqEgvzb/actions/comments&amp;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());
  }
  </code></pre>
  
  <p>I've found a number of related questions but no direct answers:</p>
  
  <p><a href="https://stackoverflow.com/questions/17178907/how-to-get-a-permanent-user-token-for-writes-using-the-trello-api">How to get a permanent user token for writes using the Trello API?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/18576765/trello-api-vote-on-a-card">Trello API: vote on a card</a></p>
  
  <p><a href="https://stackoverflow.com/questions/18710641/trello-api-how-to-post-a-card-from-google-apps-script-gas">Trello API: How to POST a Card from Google Apps Script (GAS)</a></p>
  
  <p><a href="https://stackoverflow.com/questions/10333390/google-apps-script-oauth-connect-doesnt-work-with-trello">Google apps script oauth connect doesn&#39;t work with trello</a></p>
  
  <p>Many thanks ahead of time for any advice.  </p>