在 .Net 后端 Azure 移动服务中使用 Microsoft 帐户对用户进行身份验证,登录后出现错误
Authenticate user using Microsoft Account in .Net backend Azure Mobile service giving error after login
我正在开发 Windows 10 UWP 应用程序,因为我正在使用 Microsoft 帐户作为提供者使用 Azure 移动服务实施身份验证用户。
我按照以下文章使用应用程序注册移动服务
以下是我在应用上线设置中更新的详情
我的移动服务是 .net 后端服务https://astraniprod.azure-mobile.net/
并且还更新了移动服务中的客户端 ID、密码、应用程序 SID。
之后我编写了以下代码以在我的应用程序中启动登录弹出窗口
private async System.Threading.Tasks.Task<bool> AuthenticateAsync()
{
string message;
bool success = false;
try
{
// Change 'MobileService' to the name of your MobileServiceClient instance.
// Sign-in using Facebook authentication.
user = await App.MobileService
.LoginAsync(MobileServiceAuthenticationProvider.MicrosoftAccount,true);
message =
string.Format("You are now signed in - {0}", user.UserId);
success = true;
}
catch (InvalidOperationException)
{
message = "You must log in. Login Required";
}
var dialog = new MessageDialog(message);
dialog.Commands.Add(new UICommand("OK"));
await dialog.ShowAsync();
return success;
}
}
我能够看到登录对话框并输入了我的 Microsoft 帐户和密码,之后出现以下错误
我看到其他人也在论坛上发布了关于此问题的帖子,但我没有找到问题的解决方案,我不知道问题出在哪里,其他供应商如 Google、Twitter、Facebook 正在工作很好,但只有 Microsoft 帐户无法使用。
谢谢。
我认为问题出在重定向 URI 上。
如果您打开浏览器
http://astraniprod.azure-mobile.net/login/microsoftaccount
你应该得到一个登录页面,登录,然后你会得到 "unable to complete your request" 页面。
在URL中有一个参数,说明问题:
error_description=The+provided+value+for+the+input+parameter+'redirect_uri'+is+not+valid.+The+expected+value+is+'https://login.live.com/oauth20_desktop.srf'+or+a+ URL+which+matches+the+redirect+URI+registered+for+this+client+application.
您能否确保您的应用配置为监视重定向到 https://astraniprod.azure-mobile.net/signin-microsoft
此外,请确保您按照第 2、3、4 步将您的应用与商店相关联:
https://azure.microsoft.com/en-us/documentation/articles/mobile-services-how-to-register-microsoft-authentication/
如果您已完成上述操作,它应该会起作用。如果没有,我们会帮助进一步查看。
我正在开发 Windows 10 UWP 应用程序,因为我正在使用 Microsoft 帐户作为提供者使用 Azure 移动服务实施身份验证用户。
我按照以下文章使用应用程序注册移动服务
以下是我在应用上线设置中更新的详情
我的移动服务是 .net 后端服务https://astraniprod.azure-mobile.net/
并且还更新了移动服务中的客户端 ID、密码、应用程序 SID。
之后我编写了以下代码以在我的应用程序中启动登录弹出窗口
private async System.Threading.Tasks.Task<bool> AuthenticateAsync()
{
string message;
bool success = false;
try
{
// Change 'MobileService' to the name of your MobileServiceClient instance.
// Sign-in using Facebook authentication.
user = await App.MobileService
.LoginAsync(MobileServiceAuthenticationProvider.MicrosoftAccount,true);
message =
string.Format("You are now signed in - {0}", user.UserId);
success = true;
}
catch (InvalidOperationException)
{
message = "You must log in. Login Required";
}
var dialog = new MessageDialog(message);
dialog.Commands.Add(new UICommand("OK"));
await dialog.ShowAsync();
return success;
}
}
我能够看到登录对话框并输入了我的 Microsoft 帐户和密码,之后出现以下错误
我看到其他人也在论坛上发布了关于此问题的帖子,但我没有找到问题的解决方案,我不知道问题出在哪里,其他供应商如 Google、Twitter、Facebook 正在工作很好,但只有 Microsoft 帐户无法使用。
谢谢。
我认为问题出在重定向 URI 上。
如果您打开浏览器 http://astraniprod.azure-mobile.net/login/microsoftaccount
你应该得到一个登录页面,登录,然后你会得到 "unable to complete your request" 页面。
在URL中有一个参数,说明问题: error_description=The+provided+value+for+the+input+parameter+'redirect_uri'+is+not+valid.+The+expected+value+is+'https://login.live.com/oauth20_desktop.srf'+or+a+ URL+which+matches+the+redirect+URI+registered+for+this+client+application.
您能否确保您的应用配置为监视重定向到 https://astraniprod.azure-mobile.net/signin-microsoft
此外,请确保您按照第 2、3、4 步将您的应用与商店相关联: https://azure.microsoft.com/en-us/documentation/articles/mobile-services-how-to-register-microsoft-authentication/
如果您已完成上述操作,它应该会起作用。如果没有,我们会帮助进一步查看。