我正在尝试整合一个工作流,用于通过JS后端移动服务运行Azure数据库访问,并使用Azure Active Directory(AAD)进行身份验证。从广义上讲,我一直在关注:
Add Azure Active Directory Support to Azure Mobile Services-Enabled Windows Phone Apps
我的开发和结构,有很多其他教程的阅读,例如:
Register your apps to use an Azure Active Directory Account
到目前为止,我已经使用带有客户端定向身份验证的.NET后端工作了。实际(简化的)身份验证代码如下所示:
AuthenticationResult token = await authContext.AcquireTokenSilentAsync(
AADWebApplicationAppIdUri, AADClientApplicationClientId);
if (token != null && token.Status == AuthenticationStatus.Success) {
Debug.WriteLine(token);
} else {
token = await authContext.AcquireTokenAsync(AADWebApplicationAppIdUri,
AADClientApplicationClientId, returnUri);
Debug.WriteLine(token);
}
JObject payload = new JObject();
payload["access_token"] = token.AccessToken;
MobileServiceUser msres = await App.MobileService.LoginAsync(
MobileServiceAuthenticationProvider.WindowsAzureActiveDirectory, payload);
这很好用,身份验证正确。但是,我真的想使用JS后端附带的动态模式功能。 (我确实试图使用迁移,但事实证明这比认证更令人头痛。)与.NET后端不同,JS后端不支持AAD域的客户端定向身份验证(msdn.microsoft.com/en- us / library / azure / jj710106.aspx),只有服务导向的身份验证。拼凑代码,看起来应该只是:
MobileServiceUser msres = await App.MobileService.LoginAsync(
MobileServiceAuthenticationProvider.WindowsAzureActiveDirectory);
运行,并且身份验证获取登录信息,然后失败并显示错误:
其他技术信息:
相关ID:a9397d76-0c11-4936-ae1f-749aac8fed91
时间戳:2015-02-22 03:45:14Z
AADSTS50059:在请求中找不到或由任何提供的凭据隐含的租户识别信息,并且搜索多租户应用程序标识符失败。
我无法弄清楚我的设置或代码有什么问题。如果您需要更多信息来了解正在发生的事情,请告诉我。