アクセス トークンを取得するために http ポスト リクエストを実行しようとしています。curl では、次のように動作しました。
curl -X POST 'https://www.completeurl.com' -H 'Authorization: Basic base64encodedstroing=' -H 'Content-Type: application/x-www-form-urlencoded' -d grant_type=client_credentials
json で応答を取得します: {"access_token":"tokenvalue","token_type":"bearer","expires_in":3600}
ここまでは順調ですが、今度は ServerSide Javascript で実行する必要があります。
var accessTokenUrl = "https://www.completeurl.com";
var data = "grant_type=client_credentials";
var accessHeaderNames = ["Authorization","Content-Type"];
var apiKey = "mykey";
var apiSecret = "mysecret";
var totalKey = apiKey + ":" + apiSecret;
// we need to Base64 encode the key and secret
var base64encoded = Base64Encode(totalKey);
var tokenMoney = "Basic" + " " + base64encoded;
var accessHeaderNames = ["Authorization","Content-Type"];
var accessHeaderValues = [tokenMoney, "application/x-www-form-urlencoded"];
これを次のようにまとめるにはどうすればよいですか: var accessTokenReply = HTTP.Post(accessTokenUrl,accessHeaderNames,accessHeaderValues);
動作するcurlバージョンの-dパーティーはどこに置くことができますか?