microsoftgraph / microsoftgraph/msgraph-sdk-java
Sporadic ClaimsChallengeRequiredException using client secret authentication in newer versions of SDK
还没有人认领这个 Issue。
- 主要语言
- Java
- 星标
- 444
- 派生
- 154
- 平均合并
- 18 小时 28 分钟
- 30 天内合并 PR
- 4
描述
Describe the bug
After upgrading the library to version 6.18.0 (or any version other than 6.12.0), we sporadically encounter ClaimsChallengeRequiredExceptions.
When this issue arises, the com.microsoft.graph.serviceclient.GraphServiceClient consistently returns ClaimsChallengeRequiredException, and this can persist for several hours before the problem resolves itself. The issue may or may not recur the following day, with occurrences ranging from twice a day to once every four days.
Sample response from the Graph API:
{
"error":{
"code":"InvalidAuthenticationToken",
"message":"Exception of type 'Microsoft.Graph.AGS.Contracts.ClaimsChallengeRequiredException' was thrown.",
"innerError": {"date":"2024-10-25T12:28:03", "request-id":"f9d0585e-13fc-45d5-8e04-052b9768bcc0", "client-request-id":"83e18f5d-2547-4cac-8aa1-3b11f3a8148d"}
}
}
Downgrading to 6.12.0 will cause the problem to not appea, while other applications running 6.18.0 for the same service principal still get the error.
Expected behavior
We do not expect to get sporadic ClaimsChallengeRequiredException's
How to reproduce
In our spring boot kotlin application we have defined a spring bean for a GraphServiceClient like this
@Bean
fun graphServiceClient(): GraphServiceClient {
return GraphServiceClient(
ClientSecretCredentialBuilder()
.clientId(azureProperties.clientId)
.clientSecret(azureProperties.clientSecret)
.tenantId(azureProperties.tenantId)
.build(),
SCOPES,
)
}
We also have a health check that pings
graphServiceClient.applicationsWithAppId(azureProperties.clientId).get()
to verify that the client works.
With this we can expect the exception to be thrown at any moment / random.
The following image displays occurances of this exception the last 14 days.
SDK Version
6.18.0
Latest version known to work for scenario above?
6.12.0
Known Workarounds
We have currently two workarounds:
- Restarting the application, which reinitializes the GraphServiceClient bean
or - Wait an hour or two for the problem to disappear
Other information
When running multiple instances of the same application, using the same service principal, all instances will be affected at the same time, when this issue occurs.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从使用 ClientSecretCredentialBuilder 的 GraphServiceClient bean 和 applicationsWithAppId 健康检查开始。比较 SDK 6.12.0 和 6.18.0 版本之间的身份验证行为,重点关注为什么所有使用同一 service principal 的实例会同时收到 ClaimsChallengeRequiredException。完成标准是复现该偶发异常,或确定其回归原因,并提供经过验证的修复方案。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- azure, java, kotlin, spring-boot
- 领域
- api, authentication, backend
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 25/100