【问题标题】:Authentication issues with Azure Mobile Service for Windows Phone适用于 Windows Phone 的 Azure 移动服务的身份验证问题
【发布时间】:2014-07-24 00:51:38
【问题描述】:

我正在尝试使用 Azure 移动服务的身份验证提供程序通过 Google 进行身份验证。我已按照文档 (http://azure.microsoft.com/en-us/documentation/articles/mobile-services-dotnet-backend-windows-phone-get-started-users/) 中的教程进行操作,并将其应用于我的应用程序的登录屏幕。它确实显示了 Google 的登录提示,我输入凭据并单击登录。然后,它没有像预期的那样请求同意使用我的帐户详细信息,而是返回到我的应用程序的登录屏幕。

我不确定出了什么问题,或者如何找出问题所在。我对 Windows Phone 开发和 Visual Studio 开发有点陌生,更习惯于 Android 开发和 Eclipse。这对我来说是新的,我迷路了。

这是我用于 Google 身份验证的代码。

private async System.Threading.Tasks.Task aaGoogle()
{
    while (user == null)
    {
        string message;
        try
        {
            user = await App.MobileService
                .LoginAsync(MobileServiceAuthenticationProvider.Google);
            message = string.Format("You are now logged 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();
    }
}

【问题讨论】:

  • 几件事:请仔细检查 AMS 配置中 google 项目的客户端 ID/秘密。另外,当您调试上面的代码时会发生什么?有什么例外吗?用户对象是否填写?
  • 双重检查,它们都是正确的。没有异常,并且用户对象为空,这是有道理的,因为登录过程永远不会完成。改变了一些东西,结果还是一样:没有同意屏幕。
  • 我最终创建了一个新的客户端 ID 和密码并删除了旧的。在我将 AMS 配置更改为新配置并再次尝试该应用程序后,我现在在 mscorlib.ni.dll 中得到一个“System.ArgumentException”。这可能有关系吗?

标签: c# authentication single-sign-on windows-phone-8.1 azure-mobile-services


【解决方案1】:

啊,微软的文档不完整。我正在为我的应用程序使用 .NET 后端和 C#,并且为 Javascript 后端创建了默认回调 URL。因此 .NET 后端的正确回调 URL 是:

  • [mobileservice].azure-mobile.net/signin-twitter
  • [mobileservice].azure-mobile.net/signin-facebook
  • [mobileservice].azure-mobile.net/signin-google
  • [mobileservice].azure-mobile.net/signin-microsoft

更改所有相关服务的链接后,登录屏幕和同意屏幕运行良好,我获得了每个帐户的登录详细信息。一切都按预期工作。我希望这对其他人有帮助。

【讨论】:

    猜你喜欢
    • 2015-06-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-23
    • 2015-10-01
    • 2012-02-28
    • 1970-01-01
    • 2016-07-13
    相关资源
    最近更新 更多