代表用户调用 MS Graph API 时找不到租户 'xxx'

Tenant 'xxx' not found while calling MS Graph API on behalf of a user

我正在尝试按照 this Microsoft sample 文档使用 Azure AD 实施代表流程,在客户端一切正常,但在 服务应用程序端(代表用户使用获取另一个访问令牌并再次代表用户调用 MS Graph API 的 azure 函数),它无法获取新的访问令牌(getNewAccessToken)并显示:

{
"error": "invalid_request",
"error_description": "AADSTS90002: Tenant 'xyz' not found. This may happen if there are no active subscriptions for the tenant. Check to make sure you have the correct tenant ID. Check with your subscription administrator.\r\nTrace ID: xxx \r\nCorrelation ID: yyy \r\nTimestamp: 2021-01-04 07:17:15Z",
"error_codes": [
    90002
],
"timestamp": "2021-01-04 07:17:15Z",
"trace_id": "xxx",
"correlation_id": "yyy",
"error_uri": "https://login.microsoftonline.com/error?code=90002"
}

知道如何解决这个问题吗?

根据您的错误消息,您可以导航到您的 Azure Active Directory 并确保您的 TenantID 与您的应用程序中的相匹配。

错误信息: AADSTS90002:找不到租户 'xyz'。如果租户没有活动订阅,则可能会发生这种情况。检查以确保您拥有正确的租户 ID。

TenantID