0
我正尝试在Google Apps脚本中执行以下请求。该请求将返回用于访问API的令牌。对令牌执行https POST请求
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
如何在Google Apps脚本中执行上述请求。我正在阅读,但无法找到解决方案。我尝试了类似于下面的内容,但没有奏效。 我应该使用哪些方法?
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
非常感谢现在的工作。 –