C# 身份验证-仅允许HTTPS方案

C# 身份验证-仅允许HTTPS方案,c#,authentication,azure,windows-runtime,C#,Authentication,Azure,Windows Runtime,当前正在使用连接到Azure移动服务的应用程序,需要Microsoft帐户进行身份验证 我一直遵循这一指南: 不幸的是,我遇到了这个错误:只允许https方案。我不完全确定如何修复它 错误截图: 我的代码如下,来自上面列出的指南 private async void executiveLoginBtn_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e) { await Authen

当前正在使用连接到Azure移动服务的应用程序,需要Microsoft帐户进行身份验证

我一直遵循这一指南: 不幸的是,我遇到了这个错误:只允许https方案。我不完全确定如何修复它

错误截图:

我的代码如下,来自上面列出的指南

        private async void executiveLoginBtn_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            await AuthenticateAsync();
        }

        // Define a member variable for storing the signed-in user. 
        private MobileServiceUser user;

        // Define a method that performs the authentication process
        // using a Facebook sign-in. 
        private async System.Threading.Tasks.Task AuthenticateAsync()
        {
            while (user == null)
            {
                string message;
                try
                {
                    // Change 'MobileService' to the name of your MobileServiceClient instance.
                    // Sign-in using Facebook authentication.
                    user = await App.MobileService
                        .LoginAsync(MobileServiceAuthenticationProvider.MicrosoftAccount);
                    message =
                        string.Format("You are now signed in - {0}", user.UserId);
                }
                catch (InvalidOperationException)
                {
                    message = "You must log in. Login Required";
                }

                var dialog = new MessageDialog(message);
                dialog.Commands.Add(new UICommand("OK"));
                await dialog.ShowAsync();
            }
        }
该错误还表示“WinRT信息:URI方案不是https”-因此,在验证Azure Mobile Services时,如何使URI方案成为https或以其他方式修复此错误?

1)在解决方案资源管理器中选择本地MobileService项目

2) 在属性窗口中,将SSL Enabled更改为True


3) 注意SSL URL并使用该地址初始化客户端应用程序中的MobileServiceClient对象。

我如何修复错误,如下所示:

  • SSL已启用为True


  • 输入重定向URL

  • App.xaml.cs

    public static MobileServiceClient MobileService=新的MobileServiceClient(“http://service.azure mobile.net/”,“----------------”

    改为

    公共静态MobileServiceClient MobileService=新的MobileServiceClient(“https://service.azure mobile.net/”,“----------------”


  • 我也看到了这一点。VS2015预览版。此即时堆栈跟踪是“位于Microsoft.WindowsAzure.MobileServices.AuthenticationBroker.d__4.MoveNext()的Windows.Security.Authentication.Web.WebAuthenticationBroker.AuthenticationAsync(WebAuthenticationOptions选项、Uri requestUri、Uri callbackUri)”我这边的错误似乎是因为我正在使用一个带有地址的本地MobileService项目。在MobileService项目上启用SSL并使用https://URL似乎可以消除此特定错误,但会引入其他错误。例如,在应用程序加载期间出现HttpWebRequestException的通知(不停止执行),然后在尝试使用AuthenticateTasync()时出现FileNotFoundException。是的,更改该通知似乎已修复了身份验证部分的问题。不过,我没有遇到你提到的其他例外情况。谢谢你的回复!伟大的然后我继续添加了它作为答案。我遇到了与Windows Phone 8.1通用应用程序上的操作类似的问题。我已经启用了移动服务上的SSL,但我指出,当我尝试调用LoginAsync时,该方法会挂起。我尝试该方法时也遇到了其他问题——听起来本地移动服务项目可能存在其他配置问题,我不知道。很抱歉,我无法在这方面提供更多帮助。localhost问题实际上可能与应用商店应用程序的网络隔离沙箱有关。可按此处所述进行处理: