Microsoft Graph API 逻辑应用身份验证

Microsoft Graph API Logic App Authentication

我很难让 Microsoft Graph API 调用工作。具体来说,我在身份验证过程中遇到了困难。我遵循了本文中的说明

http://martink.me/articles/using-microsoft-graph-in-logic-apps

但是,当我对 https://graph.microsoft.com/v1.0/me/messages/{id} 进行 api 调用时,出现错误:

Current authenticated context is not valid for this request. This occurs when a request is made to an endpoint that requires user sign-in. For example, /me requires a signed-in user. Acquire a token on behalf of a user to make requests to these endpoints. Use the OAuth 2.0 authorization code flow for mobile and native apps and the OAuth 2.0 implicit flow for single-page web apps.

然后我添加了一个 oAuth 令牌调用以获取令牌。然后,在进行 Microsoft Graph Api 调用时,我在授权 header 中使用了该令牌。我仍然遇到同样的错误。

任何人都可以提供有关如何最好地在 LogicApps 中进行图形 Api 调用的指导吗?我只需要文章中讨论的身份验证吗?或者,我是否需要使用授权令牌调用图 Api?在进行 oAuth 令牌调用之前是否需要进行 oAuth 授权调用?

这个异常是由使用client credentials flow获取的token引起的。在此流程中,没有 /Me.

的上下文

这种类型的授权通常用于 server-to-server 交互,这些交互必须 运行 在后台进行,无需立即与用户交互(没有用户登录)。

对于您的问题,您正在使用客户端凭证流并授予应用程序权限,因此您应该请求 /users.

 GET   https://graph.microsoft.com/v1.0/users/{id | userPrincipalName}/messages/{id}