在Azure中使用客户端凭证授予访问存储实体的资源URL是什么

发布于 2025-01-28 16:50:52 字数 856 浏览 3 评论 0原文

我正在尝试使用凭据赠款访问存储帐户(BLOB和表格)。访问令牌正在用于BLOB存储,但不用于访问表实体。

创建的代码

const data = querystring.stringify({
  client_id: this.appId,
  client_secret: this.appKey,
  grant_type: 'client_credentials',
  resource: 'https://storage.azure.com',
});
const config = {
  method: 'post',
  url: 'https://login.microsoftonline.com/' + this.DirectoryId + '/oauth2/token?api-version=1.0',
  data: data,
};
try {
  const result = await axiosInstance(config);
  return result.data.access_token;
} catch (error) {
  const errorData = error.response?.data ? error.response.data : null;
  const errorDescription = errorData && errorData.error_description ? errorData.error_description : null;
  if (errorDescription) {
    throw new Error(errorDescription);
  }
  throw error;

我尝试访问所有表实体时

,我会收到以下错误“此请求无权使用此权限执行此操作。

I am trying to access storage account (blob and table) using credential grant. The access token is working for blob storage , but not for accessing table entities.

the code for creating

const data = querystring.stringify({
  client_id: this.appId,
  client_secret: this.appKey,
  grant_type: 'client_credentials',
  resource: 'https://storage.azure.com',
});
const config = {
  method: 'post',
  url: 'https://login.microsoftonline.com/' + this.DirectoryId + '/oauth2/token?api-version=1.0',
  data: data,
};
try {
  const result = await axiosInstance(config);
  return result.data.access_token;
} catch (error) {
  const errorData = error.response?.data ? error.response.data : null;
  const errorDescription = errorData && errorData.error_description ? errorData.error_description : null;
  if (errorDescription) {
    throw new Error(errorDescription);
  }
  throw error;

when i tried accessing for get all table entities, i'm getting the below error

"This request is not authorized to perform this operation using this permission.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甜柠檬 2025-02-04 16:50:52

SDK使用范围https://storage.azure.com/.default,因此资源是正确的。

在这种情况下,该问题似乎缺少RBAC访问表的权限。

The SDK uses the scope https://storage.azure.com/.default, so that resource is correct.

In this case the issue seems to have been missing RBAC permissions to access the table.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文