0
我有一個identityServer3示例應用程序。IdentityServer3 ResourceOwner Angular請求返回400錯誤請求
public static IEnumerable<Client> GetClients()
{
return new[]
{
new Client
{
Enabled = true,
ClientId = "manager",
ClientName = "ManagerIdentity",
Flow = Flows.ResourceOwner,
ClientSecrets = new List<Secret>
{
new Secret("secret".Sha256())
},
AllowedScopes = new List<string>
{
Constants.StandardScopes.OpenId
},
AllowAccessTokensViaBrowser = true,
AllowedCorsOrigins = new List<string>{
"http://localhost:24678/" // angular application uri
}
}
}
我正在使用這些信息和請求由郵遞員和令牌返回。
但我通過發送JavaScript應用它返回400錯誤的請求angularjs同樣的要求。
angular.module("app").controller("ROPCController", [
"$scope","$http",
function($scope,$http) {
$scope.login = function() {
var options = {
"url": "http://localhost:4751/connect/token",
"method": "POST",
"data": {
"username": "muser",
"password": "password",
"grant_type": "password",
"client_id": "manager",
"client_secret": "secret",
"scope":"openid"
},
"headers": {
"Content-Type": "application/x-www-form-urlencoded"
}
};
$http(options).then(
function(response) {
console.log(response.data);
},
function(error) {
console.log(error);
}
);
}
}
]);
{「錯誤」:「invalid_client」}
我試過了,應用程序/ json內容類型返回「415不支持的媒體類型」 – barteloma
您是否還嘗試將數據格式更改爲像「data」這樣的字符串:「username = muser&password = password&grant_type = password&...」 「Content-Type」:「application/x-www-form-urlencoded」? – hakany
好的嘗試和工作的感謝。 – barteloma