我正在尝试编写一个与OAuth URL进行通信的应用.与OAuth URL的通信行为恰当,并且正确提示用户登录.但是,由于应用程序的重定向URL中的限制,我无法重定向到ms-app域(我相信您打开的方式) Windows 10上的UWP应用程序 - 如果这个假设不正确,请纠正我!).
除了托管我自己的网站并创建重定向,有谁知道如何做到这一点?
我目前用于客户端的代码是示例代码:
try
{
var webAuthenticationResult = await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.None, url);
switch (webAuthenticationResult.ResponseStatus)
{
case WebAuthenticationStatus.Success:
// Successful authentication.
result = webAuthenticationResult.ResponseData.ToString();
break;
case WebAuthenticationStatus.ErrorHttp:
// HTTP error.
result = webAuthenticationResult.ResponseErrorDetail.ToString();
break;
default:
// Other error.
result = webAuthenticationResult.ResponseData.ToString();
break;
}
}
catch (Exception ex)
{
// Authentication failed. Handle parameter, SSL/TLS, and Network Unavailable errors here.
result = ex.Message;
}
Run Code Online (Sandbox Code Playgroud)
问题表现为:
在 UWP 中,您可以通过深度链接将协议绑定到您的应用,以便它默认打开使用该协议的任何 URL。
有关深度链接的更多信息请参见此处。
基本上,您创建自己的协议(通过创建,我的意思是您只需发明一个像“my-great-protocol://”这样的字符串序列)并注册您的应用程序来响应它,它不必是 ms-app:/ /。
如果您确实无法链接到除标准协议之外的任何内容,您可以使用 URL 缩短服务,该服务将重定向到您的自定义协议。没有多少 URL 缩短服务允许这样做,但这里有一个: https: //ipkill.org
| 归档时间: |
|
| 查看次数: |
763 次 |
| 最近记录: |