我们正在使用带有 Identity Server 4 的 React Native appAuth 库(https://github.com/FormidableLabs/react-native-app-auth),并尝试在响应中使用附加参数。原因是我们在 IDS4 登录页面上有一个语言选择器,我们希望将选择的语言发送回 Native 应用程序并让 appAuth 库接收它,因此应用程序可以相应地进行调整。我如何修改身份服务器来做到这一点
return authorize(Auth.getConfig())
.then(authDetails => {
const { lang } = authDetails.additionalParameters;
if (!lang) return authDetails;
return Auth.setUserLang(lang, authDetails.accessToken).then(() => authDetails);
})
.then(authDetails => {
store.dispatch(addAuth(authDetails));
return authDetails;
})
.catch(e =>
Auth.logout().then(() => {
throw e;
})
);
static getConfig() {
const { apis: { identityServerURL } } = store.getState();
return {
issuer: identityServerURL,
clientId: IDENTITY_SERVER_CLIENT_ID,
redirectUrl,
additionalParameters: {},
scopes: ['openid', 'profile', 'offline_access'],
dangerouslyAllowInsecureHttpRequests: true,
};
}
我试过使用 ICustomAuthorizeRequestValidator
context.Result.ValidatedRequest.RedirectUri = $"{context.Result.ValidatedRequest.RedirectUri}?lang={context.Result.ValidatedRequest.UiLocales}";
但这不能作为身份服务器错误使用 "Error","MessageTemplate":"Invalid redirect_uri: {redirectUri}, expected {exceptRedirectUri}","Properties":{"redirectUri":"icisapp:/oauthredirect","exceptRedirectUri ":"icisapp:/oauthredirect?lang=zh"
有人有什么想法吗?