我正在尝试将 WebHDFS 与 Azure Data Lake 一起使用。根据微软的文档,应该遵循的步骤是:
- 在 Azure AD 中创建一个具有 Azure 管理服务的密钥和委派权限的新应用程序
使用 client_id、tenant_id 和密钥,向 OAUTH2 端点发出请求
curl -X POST https://login.microsoftonline.com/<TENANT-ID>/oauth2/token \ -F grant_type=client_credentials \ -F resource=https://management.core.windows.net/ \ -F client_id=<CLIENT-ID> \ -F client_secret=<AUTH-KEY>
成功后,您将返回一些 JSON,包括“access_token”对象,您应该通过添加标头将这些内容包含在后续 WebHDFS 请求中
Authorization: Bearer <content of "access_token">
<content of "access_token">
“access_token”对象中的长字符串在哪里。
包含该标头后,您应该能够进行 WebHDFS 调用,例如列出目录,您可以这样做
curl -i -X GET -H "Authorization: Bearer <REDACTED>" https://<yourstorename>.azuredatalakestore.net/webhdfs/v1/?op=LISTSTATUS
遵循所有这些步骤后,在运行上述 curl 命令列出目录时出现 HTTP 401 错误:
WWW-Authenticate: Bearer authorization_uri="https://login.windows.net/<REDACTED>/", error="invalid_token", error_description="The access token is invalid."
与身体
{"error":{"code":"AuthenticationFailed","message":"Failed to validate the access token in the 'Authorization' header."}}
有谁知道可能是什么问题?
我将令牌粘贴到jwt.io并且它是有效的(没有检查签名)。内容是这样的:
{
typ: "JWT",
alg: "RS256",
x5t: "MnC_VZcATfM5pOYiJHMba9goEKY",
kid: "MnC_VZcATfM5pOYiJHMba9goEKY"
}.
{
aud: "https://management.core.windows.net",
iss: "https://sts.windows.net/<TENANT-ID>/",
iat: 1460908119,
nbf: 1460908119,
exp: 1460912019,
appid: "<APP-ID>",
appidacr: "1",
idp: "https://sts.windows.net/<TENANT-ID>/",
oid: "34xxxxxx-xxxx-xxxx-xxxx-5460xxxxxxd7",
sub: "34xxxxxx-xxxx-xxxx-xxxx-5460xxxxxxd7",
tid: "<TENANT-ID>",
ver: "1.0"
}.