identityserver4 - IdnetityServer4 密码授予 javascript 400 错误请求
问题描述
我使用 javascript 发送请求:
var settings = {
method: "POST",
url: tokenEndPoint.concat("/connect/token"),
data: {
username: "username",
password: "password",
grant_type: "password",
client_id: "webui",
client_secret: "32c8e1f3-594d-406a-8e33-644cfa7959c5",
scope: "openid profile webui"
},
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
};
function onGetTokenSuccess(response) {
return response.data;
}
function onGetTokenFailed(error) {
logger.error('XHR Failed for token request.' + error);
}
$http(settings).then(onGetTokenSuccess).catch(onGetTokenFailed);
我的这个 javascript 请求给出了 Http 400 Bad request 错误。我的日志是这样的:
[12:20:22 Information] IdentityServer4.Hosting.IdentityServerMiddleware
Invoking IdentityServer endpoint: IdentityServer4.Endpoints.TokenEndpoint for /connect/token
[12:20:22 Information] IdentityServer4.Validation.TokenRequestValidator
User authentication failed: Invalid username or password.
但是这个参数使用邮递员可以正常工作。
我的客户端设置在这里:
{
"Enabled": "true",
"ClientId": "webui",
"ClientName": "Web UI",
"ClientSecrets": [
{
"Description": "32c8e1f3-594d-406a-8e33-644cfa7959c5",
"Expiration": "",
"Type": "SharedSecret",
"Value": "Q3ADcd+nptsnMpvXvCMvquwFd8i26ImBsncNGg/UG/w="
}
],
"UserClaims": [
"role"
],
"AllowedGrantTypes": [
"password"
],
"AllowedScopes": [
"openid",
"profile",
"webui"
]
}
解决方案
推荐阅读
- c++ - GetWindowTextA 无法获取 ComboBox MFC C++ 的文本
- angular - 从请求标头中删除授权,特别是 http 调用
- vue.js - Vue中如何使用动态名称vue组件?
- javascript - 从导航栏中的 li 项中添加类/删除类(React)
- javascript - 如何使用 tdbnput 从数据库中的列中获取部分文本并在 talend 中打印
- javascript - 如何使用使用的外部图像链接将网页转换为 pdf
- r - 为什么日期范围函数在 r 中不起作用
- pytorch - Cuda 内存不足 - 矩阵乘法
- java - Java:打印出整数数组的最长序列。问题出在哪里?
- java - 如何在android studio(java)中使用单击方法从圆形图像视图中显示另一个活动/片段中的图像?