angularjs - AngularJS adal 对 Azure Blob 存储的身份验证
问题描述
我有一个 angularJS 项目。我已经在我的脚本中包含了 azure-blob-storage.js,我可以使用 SAS 访问,但不能使用 AD 身份验证。
我已将 Azure 存储 API 权限添加到 AD 应用注册,并将应用阅读者和参与者角色分配给存储帐户。
adalAuthenticationService.acquireToken({clientId},
function(error, token) {
// Handle ADAL Error
if (error || !token) {
return;
}
}).then(function (token) {
var tokenCredential = new AzureStorage.Blob.TokenCredential(token);
var blobService = AzureStorage.Blob.createBlobServiceWithTokenCredential({myStorageAccountURI}, tokenCredential);
我收到以下错误:
<Error><Code>AuthenticationFailed</Code><Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature....</Message>
<AuthenticationErrorDetail>Audience validation failed. Audience did not match.</AuthenticationErrorDetail></Error>
解决方案
该错误Audience validation failed. Audience did not match.
意味着令牌受众(=预期的接收者)是错误的。您很可能会使用您的客户端 ID 为您的应用获取令牌。您需要https://storage.azure.com/
在调用acquireToken() 时将其切换到。
而且您的用户还需要拥有对 blob 的读/写访问权限,如您所见:)
推荐阅读
- apache-kafka - 如何在应用程序属性中有多个 kafka 消费者组
- excel - 有没有更有效的方法来编写具有相对单元格引用计算的 VBA?
- css - 文本区域宽度超出引导模式
- html - 如何用 CSS 制作 4 个角几何对象?
- javascript - 错误:配置验证错误:子“JWT_SECRET”失败,因为[需要“JWT_SECRET”]
- python - scipy中的多个约束
- xml - 获取包含 X 字符串的节点
- java - 如何设置组合框编辑器事件处理程序
- python - 在 AWS Sagemaker 中运行 xgb_model.fit() 时出现“[0]#011train-merror:0.17074#011validation-merror:0.1664”错误是什么?
- node.js - 关闭通知的选项