在OpenIDConnect选项下指定Redirecturi -Azure AD,.NET6 C#
我有一个Azure Active Directory,并在其下注册了我的应用程序。 在门户网站的重定向库下,我指定了此http:// custom_domain/signin-oidc。
在我的startup.cs下,我有这些代码。
services.Configure<OpenIdConnectOptions>(AzureADDefaults.OpenIdScheme, options =>
{
options.Authority = options.Authority + "/v2.0";
options.TokenValidationParameters.ValidateIssuer = false;
});
应用程序设置下指定的所有信息都是正确的(clientId,tenantid等),
当部署到我的Azure App Service时,重定向URI更改为App Service Original URL名称而不是自定义域。
执行我的应用程序时检查了登录页面: https://login.microsoftonline.com/5910deee------/oauth2/v2.0/authorize?client_id = 2782---- = https%3A%2f%2F **错误 dyirect URI未在Azure Portal AD AD REDIRECT URI **%3A444345%2FSignin-odc&amp; wendesp; wenspys_type = id_token = id_token&amp; scope = openID%20profile&amp; ansp&amp; Amp&amp; Amp; Amp; Amp; Amp; Amp; Amp; Amp; Amp; Amp; Amp; Amp; Amp; Amp; Amp; Amp; Amp; Amp; ; nonce = 6379148910548699 ......
如何在我的代码中指定重定向URI,或者将MS登录页面重定向到我的自定义域URI?在门户网站下指定 - &gt;广告 - &gt;身份验证 - &GT;重定向URI不起作用。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下是您可以遵循的解决方法以解决上述问题;
azure ad ad application application application application application reii相同的
重定向
。 > appsettings.json 文件。如 @ tinywang 所述,如果您的应用程序中有多个
重定向uri
,请删除这些,并保留在登录后要重定向的相同。,如果您已经完成了上述所有步骤,请确保您的重定向URI必须以
https
开始,而不是http
,如您所提到的http://custom_domain/signin-oidc
无效。例如,您可以设置类似: -
https://contoso.com/abc/response-oidc
。program.cs
应该看起来像这样: -和在
appsettings.json
有关完整的设置和更多信息,请参阅以下链接: -
Microsoft文档 | 支持的重定向uri 和 <强>配置文件 。
博客 | 创建ASP.NET Web应用程序(.NET Framework - Web framework或MVC)使用Azure AD ADENATICY 。 。
< em> 所以线程 @ diegosasw
建议
Below are the workaround you can follow to resolve the above issue;
redirect uri
same as on our Azure AD application(Authentication >..Redirect Uri) in yourappsettings.json
file.As stated by @Tinywang, If you have multiple
redirect uri
in your application please remove those and keep the same which you want to redirect after log-in.So if you have done with all the above steps , Please make sure that your redirect uri must be begin with
https
and nothttp
as you have mentioned in the question it ishttp://custom_domain/signin-oidc
which is not valid.For example you can set something like:-
https://contoso.com/abc/response-oidc
.Program.cs
should look like this:-And in
appsettings.json
For complete setup and more information please refer the below Links:-
MICROSOFT DOCUMENTATION|Supported redirect uri and Configuration file.
Blog| Create an ASP.NET Web Application (.NET Framework – Web Forms or MVC) using Azure AD Authentication .
SO THREAD suggested by @diegosasw