问题描述
我觉得我在这个问题上缺少基本的东西。希望有人可以给我指出解决方案或某种权威解决方案。
我们有一个SPA,该SPA调用以下代码来登录Keycloak oauth2端点。当发送包含“ @”的密码时,它们将被编码为%40,当然,用户将永远无法登录。我意识到这样做的原因是将其作为查询参数发送。但是我还没有遇到一个适用于react / redux和typescript的解决方案。虽然,看起来PHP对此有所帮助。
const makeAuthCall = (
id: NullableTypes.NullableString,password: NullableTypes.NullableString,refreshToken: NullableTypes.NullableString,): Promise<Response> => {
let body: URLSearchParams = new URLSearchParams();
const headers = new Headers({
'content-type': 'application/x-www-form-urlencoded;charset=UTF-8',});
body = new URLSearchParams({
client_id: OAUTH_CLIENT_ID,//eslint-disable-line
client_secret: OAUTH_CLIENT_SECRET,//eslint-disable-line
password: password as string,username: id as string,grant_type: OAUTH_GRANT_TYPES.PASSWORD,//eslint-disable-line
});
const requestinit: Requestinit = {
headers,method: 'POST',body: body,};
return fetchWithAuthorization(OAUTH_LOGIN_URL,requestinit);
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)