Identity Server中的本地化

问题描述 投票:1回答:1

我在Identity Server 4 Core 2.2(https://damienbod.com/2017/11/01/shared-localization-in-asp-net-core-mvc/comment-page-1/#comment-21394)中添加了共享本地化。

https://my.domain.com/Account/Register?culure=xx-YY&ui-culture=xx-YY正在工作。

现在,我如何使用本机应用程序中的OidClient LoginAsync()将culture和iu-culture参数传递给我的IdendityServer?

            var options = new OidcClientOptions
            {
                Authority = "https://my.domain.com",
                ClientId = "hybrid",
                ClientSecret = "secret",

                Scope = "openid profile api offline_access",
                ResponseMode = OidcClientOptions.AuthorizeResponseMode.Redirect,

                RedirectUri = "myscheme://signin-oidc",
                PostLogoutRedirectUri = "myscheme://signout-callback-oidc",

                Browser = new PlatformWebView()
            };

            _client = new OidcClient(options); 

            var result = await _client.LoginAsync(new LoginRequest());

谢谢。

localization identityserver4 oidc
1个回答
0
投票

一种选择是添加对名为ui_locales的OIDC可选参数的支持。 Damien Bod也有一个帖子:identityserver4-localization-using-ui_locales-and-the-query-string

要将ui_locales从客户端传递到identityserver,您可以使用FrontChannelExtraParametersLoginRequest属性。

添加到FrontChannelExtraParametersLoginRequest的参数将添加到授权URL的末尾。

如果您将代码的最后一行更改为:

var result = await _client.LoginAsync(
    new LoginRequest{ FrontChannelExtraParameters = new { ui_locales = "en-US" }} );

授权请求应如下所示:

"https://demo.identityserver.io/connect/authorize?response_type=code&nonce=20c640......&ui_locales=en-US" 
© www.soinside.com 2019 - 2024. All rights reserved.