Oauth 对令牌执行https POST请求

Oauth 对令牌执行https POST请求,oauth,google-apps-script,microsoft-translator,Oauth,Google Apps Script,Microsoft Translator,我正试图在谷歌应用程序脚本中执行以下请求。此请求将返回用于访问API的令牌 POST https://datamarket.accesscontrol.windows.net/v2/OAuth2-13 Content-Type: application/x-www-form-urlencoded client_id=USERS-CLIENT-ID&client_secret=USERS-SECRET-KEY&grant_type=client_credentials&s

我正试图在谷歌应用程序脚本中执行以下请求。此请求将返回用于访问API的令牌

POST https://datamarket.accesscontrol.windows.net/v2/OAuth2-13
Content-Type: application/x-www-form-urlencoded

client_id=USERS-CLIENT-ID&client_secret=USERS-SECRET-KEY&grant_type=client_credentials&scope=http%3a%2f%2fapi.microsofttranslator.com%2f
如何在谷歌应用程序脚本中执行上述请求。我正在读这方面的书,但找不到解决办法。我尝试了下面的方法,但没有成功。 我应该使用哪些方法

var oAuthConfig = UrlFetchApp.addOAuthService("bearer");
oAuthConfig.setConsumerKey("USERS-CLIENT-ID");
//some code omitted
//I couldn't figure out where to put grant_type and scope 
var result = UrlFetchApp.fetch("http://api.microsofttranslator.com/v2/Http.svc/Translate?text=hello&from=en&to=ja",options); //gave oAuth error

addOAuthService
实际上只适用于OAuth1服务

对于OAuth2,您需要手动执行POST调用。这里有一个例子

var parameters = {
    method : 'post',
    payload : 'client_id='+CLIENT_ID+'&client_secret='+CLIENT_SECRET+'&grant_type=authorization_code&redirect_uri='+REDIRECT_URL+'&code=' + code
  };

  var response = UrlFetchApp.fetch(TOKEN_URL,parameters).getContentText(); 
您可以在这里看到一个更完整的示例-