我希望能够从单个 Web 应用程序调用不同的应用程序寄存器。我不知道该怎么做。起初,我认为我可以向我的服务提供者添加多个 MsalAuthentication,而不是调用特定的服务提供者。我无法让它工作,所以现在我想知道是否可以更改我在开始时添加的 MsalAuthentication 的选项。
以下是我添加 MSAL 身份验证的方法:
builder.Services.AddMsalAuthentication(options =>
{
var authentication = options.ProviderOptions.Authentication;
authentication.Authority = FakeADTenant.TenantAddress;
authentication.ClientId = FakeADTenant.AppId;
authentication.ValidateAuthority = true;
options.ProviderOptions.DefaultAccessTokenScopes.Add(FakeADTenant.TokenScope);
});
另一方面,当单击登录按钮时,我正在使用此页面登录:
@page "/authentication/{action}"
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
<RemoteAuthenticatorView Action="@Action" />
@code{
[Parameter] public string Action { get; set; }
}
我想我可以在调用 RemoteAuthenticatorView 之前更改代码中的选项。我只想更改authentication.Authority、authentication.ClientId 和options.ProviderOptions.DefaultAccessTokenScopes。
最佳答案
不,作为任何 OAuth 提供商,您无法更改 clientId,权威是 OAuth 提供商 url。重定向 URI 必须与为客户端注册的 URI 匹配。您可以在授权请求中发送任何客户端允许的范围。
关于c# - 添加到服务提供者后能否更改Msal Authentication中的Authority、ClientId、DefaultAccessTokenScopes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63137614/