Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change oauth2 token request param type to FormData #853

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions knife4j-vue/public/oauth/oauth2.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,20 @@
var that=this;
console.log(this.cacheValue);
var url=this.cacheValue.tokenUrl;
var params={
"grant_type":"authorization_code",
"code":this.code,
"redirect_uri":decodeURIComponent(this.cacheValue.redirectUri),
}
var formData = new FormData();
formData.append("grant_type", "authorization_code");
formData.append("code", this.code);
formData.append("redirect_uri", decodeURIComponent(this.cacheValue.redirectUri));
formData.append("client_id", this.cacheValue.clientId);
formData.append("client_secret", this.cacheValue.clientSecret);
let instance=axios.create();
let requestConfig={
url: url,
method: 'post',
timeout: 0,
//此data必传,不然默认是data:undefined,https://github.com/axios/axios/issues/86
//否则axios会忽略请求头Content-Type
data: `client_id=${this.cacheValue.clientId}&client_secret=${this.cacheValue.clientSecret}`,
params:params
data: formData
}
instance.request(requestConfig).then(res=>{
let data=res.data;
Expand Down
16 changes: 7 additions & 9 deletions knife4j-vue3/public/oauth/oauth2.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,20 @@
var that=this;
console.log(this.cacheValue);
var url=this.cacheValue.tokenUrl;
var params={
"grant_type":"authorization_code",
"code":this.code,
"redirect_uri":decodeURIComponent(this.cacheValue.redirectUri),
"client_id":this.cacheValue.clientId,
"client_secret":this.cacheValue.clientSecret
}
var formData = new FormData();
formData.append("grant_type", "authorization_code");
formData.append("code", this.code);
formData.append("redirect_uri", decodeURIComponent(this.cacheValue.redirectUri));
formData.append("client_id", this.cacheValue.clientId);
formData.append("client_secret", this.cacheValue.clientSecret);
let instance=axios.create();
let requestConfig={
url: url,
method: 'post',
timeout: 0,
//此data必传,不然默认是data:undefined,https://github.com/axios/axios/issues/86
//否则axios会忽略请求头Content-Type
data: null,
params:params
data: formData
}
instance.request(requestConfig).then(res=>{
let data=res.data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,20 @@
var that=this;
console.log(this.cacheValue);
var url=this.cacheValue.tokenUrl;
var params={
"grant_type":"authorization_code",
"code":this.code,
"redirect_uri":decodeURIComponent(this.cacheValue.redirectUri),
}
var formData = new FormData();
formData.append("grant_type", "authorization_code");
formData.append("code", this.code);
formData.append("redirect_uri", decodeURIComponent(this.cacheValue.redirectUri));
formData.append("client_id", this.cacheValue.clientId);
formData.append("client_secret", this.cacheValue.clientSecret);
let instance=axios.create();
let requestConfig={
url: url,
method: 'post',
timeout: 0,
//此data必传,不然默认是data:undefined,https://github.com/axios/axios/issues/86
//否则axios会忽略请求头Content-Type
data: `client_id=${this.cacheValue.clientId}&client_secret=${this.cacheValue.clientSecret}`,
params:params
data: formData
}
instance.request(requestConfig).then(res=>{
let data=res.data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,12 @@
var that=this;
console.log(this.cacheValue);
var url=this.cacheValue.tokenUrl;
var params={
"grant_type":"authorization_code",
"code":this.code,
"redirect_uri":decodeURIComponent(this.cacheValue.redirectUri),
"client_id":`${this.cacheValue.clientId}`,
"client_secret":`${this.cacheValue.clientSecret}`
}
var formData = new FormData();
formData.append("grant_type", "authorization_code");
formData.append("code", this.code);
formData.append("redirect_uri", decodeURIComponent(this.cacheValue.redirectUri));
formData.append("client_id", this.cacheValue.clientId);
formData.append("client_secret", this.cacheValue.clientSecret);
let instance=axios.create();
let requestConfig={
url: url,
Expand All @@ -80,7 +79,7 @@
//此data必传,不然默认是data:undefined,https://github.com/axios/axios/issues/86
//否则axios会忽略请求头Content-Type
// spring-authorization-server only support get param form request body,see https://github.com/spring-projects/spring-authorization-server/issues/1451
data: params,
data: formData,
// params:params
}
instance.request(requestConfig).then(res=>{
Expand Down