microsoftgraph / microsoftgraph/msgraph-sdk-java

Enable automatic token refresh when Continuous Access Evaluation (CAE) requires a new token

未关闭
#2,306 11 条评论 9 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

status:waiting-for-triage type:bug
主要语言
Java
星标
444
派生
154
平均合并
18 小时 28 分钟
30 天内合并 PR
4

描述

Describe the bug

When using the AzureIdentityAuthenticationProvider with ClientCertificateCredential, the authentication process does not automatically refresh the token when CAE forces a new authentication. This results in InteractionRequired and TokenCreatedWithOutdatedPolicies errors during Microsoft Graph API calls.

Expected behavior

The AzureIdentityAuthenticationProvider should detect when CAE requires a new token and automatically refresh it to prevent authentication failures.

How to reproduce
  1. Configure authentication using ClientCertificateCredential and AzureIdentityAuthenticationProvider.
  2. Enable CAE in the Azure AD tenant.
  3. Call a Microsoft Graph API endpoint that requires authentication.
  4. If CAE enforces a re-authentication, the request fails with the error:
    Continuous access evaluation resulted in challenge with result: InteractionRequired and code: TokenCreatedWithOutdatedPolicies
SDK Version

6.26.0

Latest version known to work for scenario above?

No response

Known Workarounds

Manually regenerating the GraphServiceClient instance or completely restarts the application.

Debug output

The provider does not refresh the token, causing repeated authentication errors when CAE is triggered.


Caused by: com.microsoft.graph.models.odataerrors.ODataError: Continuous access evaluation resulted in challenge with result: InteractionRequired and code: TokenCreatedWithOutdatedPolicies
	at com.microsoft.graph.models.odataerrors.ODataError.createFromDiscriminatorValue(ODataError.java:36)
	at com.microsoft.kiota.serialization.JsonParseNode.getObjectValue(JsonParseNode.java:212)
	at com.microsoft.kiota.http.OkHttpRequestAdapter.lambda$throwIfFailedResponse$0(OkHttpRequestAdapter.java:673)
	at com.microsoft.kiota.ApiExceptionBuilder.<init>(ApiExceptionBuilder.java:26)
	at com.microsoft.kiota.http.OkHttpRequestAdapter.throwIfFailedResponse(OkHttpRequestAdapter.java:672)
	at com.microsoft.kiota.http.OkHttpRequestAdapter.send(OkHttpRequestAdapter.java:280)
	at com.microsoft.graph.sites.item.drive.DriveRequestBuilder.get(DriveRequestBuilder.java:59)
	at com.microsoft.graph.sites.item.drive.DriveRequestBuilder.get(DriveRequestBuilder.java:46)

Configuration

Microsoft Graph SDK version: 6.26.0
Java version: 21
Spring Boot version: 3.3
Authentication method: ClientCertificateCredential

Other information

Manually regenerating the GraphServiceClient instance as a workaround is inefficient. It would be beneficial if the SDK could handle this scenario internally.

Would it be possible to enhance AzureIdentityAuthenticationProvider to handle CAE-related token refresh automatically?

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 AzureIdentityAuthenticationProvider 及其在 Microsoft Graph API 调用期间与 ClientCertificateCredential 的交互开始。重现 CAE 错误,然后跟踪 provider 如何处理失败的请求和令牌状态。当 CAE 触发的身份验证刷新能够自动进行,而无需重新创建 GraphServiceClient 或重启应用程序时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
azure, java
领域
api, authentication
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
活跃
描述清晰度
基本清楚
新手友好度
48/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。