在离子应用程序中访问 jhipster Oauth2 认证的 REST API
Access jhipster Oauth2 authenticated REST API in ionic app
虽然在我的 ionic app 中访问 jhipster Oauth2 API 但我我没有得到回应。这是我从我的离子应用程序
发送的 $http 请求
$http({
method: "post",
url: "http://192.168.0.5:8080/auth-2-sconnect/oauth/token",
data: "username=admin&password=admin&grant_type=password&scope=read write&client_secret=my-secret-token-to-change-in-production&client_id=auth2Sconnectapp",
withCredentials: true,
headers: {
'Accept':'application/json',
'Content-Type': 'application/x-www-form-urlencoded'
}
})
.success(function(data) {
alert("success: " + data);
})
.error(function(data, status) {
alert("ERROR: " + data);
});
如果我插入
它也会给出**Status Code:403 Forbidden**
错误
'Authorization': 'Basic ' + 'YXV0aDJTY29ubmVjdGFwcDpteS1zZWNyZXQtdG9rZW4tdG8tY2hhbmdlLWluLXByb2R1Y3Rpb24='
里面headers
我在 jhipster 应用程序的 application.yml 中取消了对 CORS 的注释,这似乎可以解决问题。
我的离子应用程序现在工作正常。
虽然在我的 ionic app 中访问 jhipster Oauth2 API 但我我没有得到回应。这是我从我的离子应用程序
发送的 $http 请求$http({
method: "post",
url: "http://192.168.0.5:8080/auth-2-sconnect/oauth/token",
data: "username=admin&password=admin&grant_type=password&scope=read write&client_secret=my-secret-token-to-change-in-production&client_id=auth2Sconnectapp",
withCredentials: true,
headers: {
'Accept':'application/json',
'Content-Type': 'application/x-www-form-urlencoded'
}
})
.success(function(data) {
alert("success: " + data);
})
.error(function(data, status) {
alert("ERROR: " + data);
});
如果我插入
它也会给出**Status Code:403 Forbidden**
错误
'Authorization': 'Basic ' + 'YXV0aDJTY29ubmVjdGFwcDpteS1zZWNyZXQtdG9rZW4tdG8tY2hhbmdlLWluLXByb2R1Y3Rpb24='
里面headers
我在 jhipster 应用程序的 application.yml 中取消了对 CORS 的注释,这似乎可以解决问题。
我的离子应用程序现在工作正常。