0
我試圖返回在YouTube API的訪問令牌,但不知道如何在JQuery的HTTP Post在JQuery的
POST /oauth2/v4/token HTTP/1.1
Host: www.googleapis.com
Content-length: 184
content-type: application/x-www-form-urlencoded
user-agent: google-oauth-playground
client_secret=************&grant_type=refresh_token&refresh_token=1%2FPHiWsKPQXQJCNKBbTPgiR0QHugKlXp8Pd2cRlohjK80hAConmTyV5XVmg2HfO4Ag&client_id=407408718192.apps.googleusercontent.com
格式化這個POST
感謝您的幫助!
編輯:這是到目前爲止我的代碼
jQuery.ajax({
url: "https://www.googleapis.com/oauth2/v4/token/",
type: "post",
data: {
grant_type: "refresh_token",
refresh_token: 'token here',
client_id: 'id here',
client_secret: 'secret here',
access_type: 'offline',
},
success: function(response){
console.log(response)
}
})
};
http://stackoverflow.com/questions/5771878/jquery-ajax-request-change-user-agent + https://api.jquery.com/jquery.post/應該爲你足以用作參考。你有任何目前嘗試的代碼顯示在這裏? – G0dsquad
@ G0dsquad迄今爲止添加了我的代碼的編輯,感謝您的回覆 –
您需要發佈參數,而不僅僅是將它們粘貼在http get請求的末尾。 – DaImTo