无法将 Microsoft.Azure.Mobile.Server.Authentication 安装到 Xamarin Forms
Failed to install Microsoft.Azure.Mobile.Server.Authentication into Xamarin Forms
我正在尝试将 Microsoft.Azure.Mobile.Server.Authentication 添加/安装到我的 PCL 项目中,但出现错误
Could not install package 'Microsoft.Azure.Mobile.Server 2.0.0'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile49', but the package does not contain any assembly references or content files that are compatible with that framework.
我试过安装以前的版本,但出现了完全相同的错误。我还尝试将 Framework 版本更改为 .NET 4.6,但出现了其他错误。
我想使用仅受该命名空间支持的 GetAppServiceIdentityAsync() 方法。有没有其他方法将该引用添加到我的 PCL 项目中?
您是否尝试过将 Android API 级别设置为更高级别?我在安装 Moq 时遇到了这个错误,我可以通过将 Android API 级别更改为最高 API 级别来解决这个问题。请尝试将 Android 7.1 (Nougat) 与 API-Level 25 一起使用,同时使用最低 SDK。
您可以通过以下方式更改它:右键单击项目 -> 选项 -> 构建 -> 常规 -> Android 应用程序
在常规下,您还可以尝试将应用的目标版本更改为更高级别。
据我所知,GetAppServiceIdentityAsync 用于检索 Identity
(ProviderCredentials) for the specific provider in your server-side code. For your mobile client, I assumed that you could leverage MobileServiceClient.InvokeApiAsync<List<AppServiceIdentity>>("/.auth/me");
to retrieve the identities and filter them with the specific provider, them you could get Provider
, UserId
and UserClaims
properties as you expected. For more details, you could refer to Obtaining User Claims.
Azure Mobile Apps 有两个版本 - 一个在服务器上运行,另一个在客户端上运行。您正在尝试使用服务器版本并且需要 ASP.NET 和 .NET Framework 4.5+(目前为 4.6)。它在您的客户端中不起作用。
如果您在服务器上使用 Azure 移动应用,那么您已经添加了对 Microsoft.Azure.Mobile.Client 的引用并创建了对 Azure 应用服务的移动客户端引用。您还已经配置了 Azure 移动应用服务器并使用 Azure 应用服务身份验证链接了您的身份验证提供程序。如果您还没有,请查看这本书 http://aka.ms/zumobook - 这将为您提供正确的指导。
如果你仍然支持我,那么你需要与你的 Azure 应用服务建立 HTTPS 连接 URL + /.auth/me - 这个 returns a JSON blob,其中包含 Azure 应用服务身份验证知道的提供程序信息。该服务知道的其中一件事是用于身份验证的身份验证令牌。然后,如果用户不在 JSON blob 中,您可以使用此身份验证令牌获取有关用户的其他信息。
获取该信息的一个好方法是使用 Bruce 提到的 client.InvokeApiAsync<>()
方法。书中也有介绍。
我正在尝试将 Microsoft.Azure.Mobile.Server.Authentication 添加/安装到我的 PCL 项目中,但出现错误
Could not install package 'Microsoft.Azure.Mobile.Server 2.0.0'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile49', but the package does not contain any assembly references or content files that are compatible with that framework.
我试过安装以前的版本,但出现了完全相同的错误。我还尝试将 Framework 版本更改为 .NET 4.6,但出现了其他错误。
我想使用仅受该命名空间支持的 GetAppServiceIdentityAsync() 方法。有没有其他方法将该引用添加到我的 PCL 项目中?
您是否尝试过将 Android API 级别设置为更高级别?我在安装 Moq 时遇到了这个错误,我可以通过将 Android API 级别更改为最高 API 级别来解决这个问题。请尝试将 Android 7.1 (Nougat) 与 API-Level 25 一起使用,同时使用最低 SDK。
您可以通过以下方式更改它:右键单击项目 -> 选项 -> 构建 -> 常规 -> Android 应用程序
在常规下,您还可以尝试将应用的目标版本更改为更高级别。
据我所知,GetAppServiceIdentityAsync 用于检索 Identity
(ProviderCredentials) for the specific provider in your server-side code. For your mobile client, I assumed that you could leverage MobileServiceClient.InvokeApiAsync<List<AppServiceIdentity>>("/.auth/me");
to retrieve the identities and filter them with the specific provider, them you could get Provider
, UserId
and UserClaims
properties as you expected. For more details, you could refer to Obtaining User Claims.
Azure Mobile Apps 有两个版本 - 一个在服务器上运行,另一个在客户端上运行。您正在尝试使用服务器版本并且需要 ASP.NET 和 .NET Framework 4.5+(目前为 4.6)。它在您的客户端中不起作用。
如果您在服务器上使用 Azure 移动应用,那么您已经添加了对 Microsoft.Azure.Mobile.Client 的引用并创建了对 Azure 应用服务的移动客户端引用。您还已经配置了 Azure 移动应用服务器并使用 Azure 应用服务身份验证链接了您的身份验证提供程序。如果您还没有,请查看这本书 http://aka.ms/zumobook - 这将为您提供正确的指导。
如果你仍然支持我,那么你需要与你的 Azure 应用服务建立 HTTPS 连接 URL + /.auth/me - 这个 returns a JSON blob,其中包含 Azure 应用服务身份验证知道的提供程序信息。该服务知道的其中一件事是用于身份验证的身份验证令牌。然后,如果用户不在 JSON blob 中,您可以使用此身份验证令牌获取有关用户的其他信息。
获取该信息的一个好方法是使用 Bruce 提到的 client.InvokeApiAsync<>()
方法。书中也有介绍。