Javascript microsoft graph客户端凭据-代表用户发送电子邮件时发生get-oauth错误

Javascript microsoft graph客户端凭据-代表用户发送电子邮件时发生get-oauth错误,javascript,microsoft-graph-api,Javascript,Microsoft Graph Api,我成功地为Microsoft Graph设置了OAuth 2.0客户端凭据,我获得了auth令牌,没有问题,订阅了接收多个用户的电子邮件Webhook,并获得了这些电子邮件通知 在Azure Portal中,我将应用程序设置为具有“以任何用户身份发送邮件”的Microsoft Graph应用程序级别权限 我正在尝试使用Graph转发电子邮件,但收到BadRequest错误: { "error": { "code": "BadRequest", "message":

我成功地为Microsoft Graph设置了OAuth 2.0客户端凭据,我获得了auth令牌,没有问题,订阅了接收多个用户的电子邮件Webhook,并获得了这些电子邮件通知

在Azure Portal中,我将应用程序设置为具有“以任何用户身份发送邮件”的Microsoft Graph应用程序级别权限

我正在尝试使用Graph转发电子邮件,但收到
BadRequest
错误:

{
  "error": {
    "code": "BadRequest",
    "message":
      "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.",
    "innerError": {
      "request-id": "a64c4533-9389-4284-8cf5-68fcadf21832",
      "date": "2018-05-27T17:34:29"
    }
  }
}
以下是我发送请求的方式:

postData(
    `${graphVersion}/me/messages/${req.body.emailUid}/forward`,
    global.accessToken,
    JSON.stringify(forwardConfiguration),
    (requestError, data) => {
        if (requestError) {
            logger.log('error', "Failed to forward email: " + JSON.stringify(requestError));
        } else {
            logger.log("info", "Successfully forwarded email from " + req.body.email);
        }
    }
);

您不能将
/me
与客户端凭据一起使用

这是因为
/me
只是
/user/{currentUser}
的别名。使用客户端凭据时,API也没有“用户”来映射此别名

您需要明确指定所需的
用户

/users/{userId or userPrincipalName}/messages

forwardConfiguration
的内容是什么?Marc,非常感谢您的快速帮助。我在帖子url中设置了合适的用户。起初它不起作用,因为我向req传递了一个无效的电子邮件ID,但现在它起作用了。能得到像你这样的专家的帮助真是太棒了,我真的很感激!