azure - 访问 Cosmos DB 文档的授权 token

标签 azure xamarin.forms azure-active-directory azure-cosmosdb azure-ad-b2c

我尝试使用 Azure AD B2C 和 MSAL 使用用户名和密码登录。登录后,我们使用 Web API 验证访问 token ,该 API 返回资源 token ,获取它后,我们使用资源 token 连接 DocumentClient,如下所述,但是当我们尝试在 Cosmos DB 中执行诸如 savedocument 之类的操作时,面临以下错误

var Client = new DocumentClient(new System.Uri(App.accURL), resourceToken);

消息:

{"Errors": ["Authorization Token doesn't present sufficient permissions to serve the request."]}

ActivityId: 3360415e-b937-4061-b74d-485d44550df2,

Request URI: /apps/7dc938ac-8c47-4af3-9760-5e80284624b0/services/4344f786-4b9a-4293-ab0a-d27a5ccae76a/partitions/26b66fff-1ad2-47dc-90c8-cc9ee7b0d23b/replicas/131448621059935679p: Error: ...

最佳答案

when we try to perform the action like savedocument in cosmosDB, facing following error. Authorization Token doesn't present sufficient permissions to serve the request.

据我所知,我们只能将一个权限与用户的特定资源关联起来。并且权限模式只有两种:全部(读、写、删除权限)或。如果您为用户指定的配置正确,我建议您检查 permissionModeResourceLinkResourceTokenExpirySeconds

你可以List Permissions for a user并使用DocumentClient.ReadPermissionFeedAsync用于检索用户的权限。另外,您可以引用相关教程Permissions in Azure DocumentDBCosmos DB > Permissions .

如果您仍然无法找到此问题,请使用相关代码更新您的问题,以向您的用户授予权限并利用 fiddler使用 resourceToken token 访问资源时收集网络跟踪。

关于azure - 访问 Cosmos DB 文档的授权 token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45525096/

相关文章:

azure - Azure AD "classic"、ADFS "3.0"和 B2C 之间的确切协议(protocol)差异是什么

azure - 是否可以创建已弃用的 Azure 数字孪生版本?

azure - 检测并删除 Azure 服务总线上的孤立队列、主题或订阅

xamarin.forms - ELCImagePicker - NuGet 包

azure-active-directory - 如何使用 AzureAD 和 Microsoft.Identity.Web 在 Blazor 服务器中调用 "SignOut"?

c# - 等待杀死进程

azure - PartitionKey可以用StartsWith查询吗?

azure - 将 Azure 函数作为 C# Web 应用程序进行调试

xaml - TitleView 未覆盖整个工具栏

c# - 在 Xamarin Forms 中应该使用哪个包而不是 Android.Content 来获取类 Intent?