gpt4 book ai didi

c# - Xamarin.Auth - UWP - Windows 拦截的重定向 URL

转载 作者:太空宇宙 更新时间:2023-11-03 14:47:23 32 4
gpt4 key购买 nike

我正在使用程序包 Xamarin.Auth 根据我的 UWP 应用程序中的身份验证服务对用户进行身份验证。

验证器实例化如下:

this.Authenticator = new OAuth2Authenticator(
CLIENT_ID,
CLIENT_SECRET,
"openid profile",
new Uri("https://<authentication-example-server>/authorize"),
new Uri("my-app://oauth2redirect"),
new Uri("https://<authentication-example-server>/access_token"),
GetUsernameAsync,
isUsingNativeUI: false);
this.Authenticator.Completed += this.OnAuthenticationCompleted;

稍后我启动身份验证过程:

var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter();
presenter.Login(this.Authenticator);

到目前为止,一切都按预期进行,身份验证工作正常。但是,我在重定向时遇到问题。尽管使用自定义 URL 的重定向会调用应用程序本身并调用方法

protected override void OnActivated(IActivatedEventArgs args)

正如预期的那样,Windows 总是会触发一个额外的对话窗口: Did you meant to switch apps?

如何在不更改注册表或任何系统范围设置的情况下避免身份验证过程的拦截?实际上,该应用程序只是在调用自身,因此我不明白为什么会触发消息。我必须使用其他重定向方法吗?

我也试过用户 isUsingNativeUI: true 并且没有任何改变。

最佳答案

看起来重定向参数(my-app://oauth2redirect) 被认为是应用程序启动uri。您可以将它修改为另一个,例如 https://auth0.com/

this.Authenticator = new OAuth2Authenticator(
CLIENT_ID,
CLIENT_SECRET,
"openid profile",
new Uri("https://<authentication-example-server>/authorize"),
new Uri("https://auth0.com/"),
new Uri("https://<authentication-example-server>/access_token"),
GetUsernameAsync,
isUsingNativeUI: false);

关于c# - Xamarin.Auth - UWP - Windows 拦截的重定向 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53554174/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com