2
salesforce oath2のaccess_tokenを取得できました。アクセストークンは、しばらくしてから期限切れになる可能性があります。その後、アクセストークンを更新する必要があります。しかし、私はこのコードでは常に "Bad Request"エラーが発生しています。salesforceで常に「不正なリクエスト」エラーが発生するoauth 2認証でappceleratorを使用
function getRefreshToken(refreshToken) {
var url = loginUrl + 'token';
var client = Ti.Network.createHTTPClient({
// // function called when the response data is available
onload : function(e) {
Ti.API.info("Received text: " + this.ResponseText);
alert(this.status);
alert(this.responseText);
},
// function called when an error occurs, including a timeout
onerror : function(e) {
Ti.API.debug(e.error);
alert(this.status);
alert(e.error);
},
timeout : 5000 //in milliseconds
});
//Prepare the connection.
client.open("POST", url);
client.setRequestHeader("content-type", "application/json");
//Send the request.
var param = 'grant_type=refresh_token&client_id=' + escape(clientId) + '&client_secret='+ escape(clientSecret) + '&refresh_token=' + escape(refreshToken);
Ti.API.info(param);
client.send(param);
}
私はこのコードに何か不足していますか?期待される結果は、新しいaccess_tokenでjsonの応答です。
私は" x-www-form-urlencoded "を使う必要があるという問題があります。 – Vivart