我正在使用 Angular 8 开发一个应用程序并尝试连接到 Azure Data Lake Gen 2's FileSystem通过其 REST API以便能够检索文件夹列表以及进行文件导入。
对于身份验证,我使用库 msal-angular这允许我通过 loginPopup
检索ID token 函数和通过 acquireTokenSilent
的访问 token 功能。
我使用这个方案作为指导:aad connection flow
范围:['user.read','api://<uuid>/user_impersonation']
。 api scopes
然后我使用storage-datalake库来尝试从我的数据湖检索信息。因此,我使用登录用户的访问 token 来创建 DataLakeStorageClient
与 TokenCredentials
。然后我尝试恢复我的文件系统之一上的文件夹列表。
我收到此错误:401 (Server failed to authenticate the request. Please refer to the information in the www-authenticate header.)
.
Do you have any idea where my problem might come from?
我的用户具有以下 Angular 色:
- 贡献者
- 存储 Blob 数据贡献者
API 权限: api permissions
当我使用END-USER authentication时没有用户模拟(作为服务主体)我可以访问我的文件系统...
提前感谢您的帮助。
最佳答案
范围不正确。您不能在范围内使用两种资源。 user.read
用于https://graph.microsoft.com
资源。 api://<uuid>/user_impersonation
用于您自己的资源。
您可以尝试使用['https://datalake.azure.net/.default']
作为范围。
关于angular - 无法使用 azure-sdk-for-js 通过 Angular 访问 Azure Data Lake Gen2 的文件系统,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58622056/