【问题标题】:Regarding Microsoft Graph API integration in Angular - Spring Boot application关于 Angular 中的 Microsoft Graph API 集成 - Spring Boot 应用程序
【发布时间】:2020-08-22 06:14:28
【问题描述】:

您遇到问题的图形 API 请求 https://graph.microsoft.com/v1.0/me/messages

Graph API error message


 {
        'error': {
        'code': 'InvalidAuthenticationToken',
        'message': 'Access token validation failure. Invalid audience.',
        'innerError': {
        'request-id': '12e4940d-58af-4d64-98ab-4b3fe645afb8',
        'date': '2020-05-05T13:57:38'
        }
    }
    }

说明: 实施用例,用户可以在我们的应用程序中提取电子邮件,以使用 Microsoft graph 下载附件并将其合并到中心位置。

Web 应用前端使用 Angular 开发,后端使用 Spring Boot REST API 开发。

在 Angular 中集成 MSAL 以验证用户并获取有效令牌。

code configuration :
MsalModule.forRoot({
clientID: '83de5e6f-6a5b-48f4-8b64-5e8d6e70aa9d',
authority: 'https://login.microsoftonline.com/common/',
redirectUri: 'http://localhost:4200/TestLawyer/mail',
cacheLocation: 'localStorage',
// storeAuthStateInCookie: isIE, // set to true for IE 11
popUp: true,
consentScopes: ['user.read'],
unprotectedResources: ['https://www.microsoft.com/en-us/'],
protectedResourceMap: protectedResourceMap,
// logger: loggerCallback,
correlationId: '1234',
piiLoggingEnabled: true
})

我在本地存储中获得了令牌。在我的解决方案中,我想将令牌传递给我们的 Spring Boot Rest 服务器,以使用 Microsoft Graph 提取电子邮件。

您能否像实施此用例的任何教程或指南一样帮助我。

【问题讨论】:

    标签: microsoft-graph-api access-token


    【解决方案1】:

    您的令牌的资源或范围不正确。

    您应该在许可范围中设置https://graph.microsoft.com/.default

    您可以在https://jwt.io 中解码您的访问令牌,以查看令牌是否包含正确的资源/范围。

    【讨论】:

      猜你喜欢
      • 2019-09-25
      • 1970-01-01
      • 2018-10-31
      • 1970-01-01
      • 2018-10-19
      • 1970-01-01
      • 2019-08-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多