如何验证 Hugging Face 组织令牌?
How to validate Hugging Face organization token?
/whoami-2
端点 returns Unauthorized
用于组织令牌,以 api_...
.
开头的那些
$ curl https://huggingface.co/api/whoami-2 -H "Authorization: Bearer api_<token>"
> { "error": "Unauthorized" }
同时我可以使用相同的token来获取私有模型。我应该使用其他端点来验证令牌吗?
您正在请求错误的端点。端点似乎已更新,我在向旧端点 (whoami
) 发送请求时遇到了类似的错误。
只需将请求发送至 whoami-v2
,例如:
$ curl https://huggingface.co/api/whoami-v2 -H "Authorization: Bearer ${token}"
> {"type": "","name":"sadra","fullname":"sadra","email":"","emailVerified":true,"plan":"","periodEnd":,"avatarUrl":"","orgs":[]}
注意:根据 docs,旧标记似乎是 api_XXX
或 api_org_XXX
,而所有新标记都以 hf_XXX
开头。因此,如果您仍然面临新端点的问题,创建新令牌可能会有所帮助。
因此,组织令牌也会发生同样的事情:
$ curl https://huggingface.co/api/whoami-v2 -H "Authorization: Bearer api_org_XXX"
> {"type":"org","name":"testmy","fullname":"testorg","email":null,"plan":"NO_PLAN","periodEnd":null,"avatarUrl":"https://www.gravatar.com/avatar/1bd0170cca6f638f0dd02c6a79e8c270?d=retro&size=100"}
/whoami-2
端点 returns Unauthorized
用于组织令牌,以 api_...
.
$ curl https://huggingface.co/api/whoami-2 -H "Authorization: Bearer api_<token>"
> { "error": "Unauthorized" }
同时我可以使用相同的token来获取私有模型。我应该使用其他端点来验证令牌吗?
您正在请求错误的端点。端点似乎已更新,我在向旧端点 (whoami
) 发送请求时遇到了类似的错误。
只需将请求发送至 whoami-v2
,例如:
$ curl https://huggingface.co/api/whoami-v2 -H "Authorization: Bearer ${token}"
> {"type": "","name":"sadra","fullname":"sadra","email":"","emailVerified":true,"plan":"","periodEnd":,"avatarUrl":"","orgs":[]}
注意:根据 docs,旧标记似乎是 api_XXX
或 api_org_XXX
,而所有新标记都以 hf_XXX
开头。因此,如果您仍然面临新端点的问题,创建新令牌可能会有所帮助。
因此,组织令牌也会发生同样的事情:
$ curl https://huggingface.co/api/whoami-v2 -H "Authorization: Bearer api_org_XXX"
> {"type":"org","name":"testmy","fullname":"testorg","email":null,"plan":"NO_PLAN","periodEnd":null,"avatarUrl":"https://www.gravatar.com/avatar/1bd0170cca6f638f0dd02c6a79e8c270?d=retro&size=100"}