InteractionRequiredAuthError not caught in AuthCodeMSALBrowserAuthenticationProvider
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 55/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 停滞
- 技术栈
- typescript
调研方向
Start with src/authentication/msal-browser/AuthCodeMSALBrowserAuthenticationProvider.ts, especially the getAccessToken path referenced in the issue, and reproduce the request with a newly added scope. Confirm that an InteractionRequiredAuthError caused by missing consent reaches the configured popup or redirect flow and that the Graph request can then succeed.
由索引模型根据 Issue 内容生成。
描述
Describe the bug
I am trying to increment my consent using and new scope using the AuthCodeMSALBrowserAuthenticationProvider but the browser doesn't prompt for interaction via the specified interaction type. (Popup / Redirect)
Expected behavior
If the scope doesn't exist the existing token the user should be prompted to consent.
How to reproduce
Setup the AuthCodeMSALBrowserAuthenticationProvider with a scope not previously consented.
const authProvider = new AuthCodeMSALBrowserAuthenticationProvider(
instance as PublicClientApplication,
{
scopes: ["User.Read", "User.ReadBasic.All"],
account: instance.getActiveAccount()!,
interactionType: InteractionType.Redirect,
}
);
Attempt to call the GraphClient
const graphClient = Client.initWithMiddleware({
authProvider,
});
const user: User = await graphClient
.api("/me")
.select([
"displayName",
"givenName",
"id",
"mail",
"mobilePhone",
"officeLocation",
"preferredLanguage",
"surname",
"userPrincipalName",
"jobTitle",
"companyName",
])
.get();
SDK Version
3.0.7
Latest version known to work for scenario above?
No response
Known Workarounds
Specify the scopes in initial interactive login.
Debug output
Click to expand log
```Uncaught (in promise) _GraphError: invalid_grant: AADSTS65001: The user or administrator has not consented to use the application with ID 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' named 'xxxxxxx'. Send an interactive authorization request for this user and resource. Trace ID: 53d15b9f-5e08-4e70-90fc-1448ddff9000 Correlation ID: 01992380-12dc-70c6-a2a2-33f9f074dd3b Timestamp: 2025-09-07 09:27:00Z
</details>
### Configuration
_No response_
### Other information
It would seem that the error thrown is not being caught as an instance of InteractionRequiredAuthError here.
[AuthCodeMSALBrowserAuthenticationProvider.ts](https://github.com/microsoftgraph/msgraph-sdk-javascript/blame/db1757abe7a4cad310f0cd4d7d2a83b961390cce/src/authentication/msal-browser/AuthCodeMSALBrowserAuthenticationProvider.ts#L65C5-L76C4)
Setting a breakpoint and inspecting the output shows this:-
**error**
:
Error at new GraphClientError2 (http://localhost:5173/node_modules/.vite/deps/@microsoft_microsoft-graph-client_authProviders_authCodeMsalBrowser.js?v=3372f56d:16797:30) at AuthCodeMSALBrowserAuthenticationProvider2.<anonymous> (http://localhost:5173/node_modules/.vite/deps/@microsoft_microsoft-graph-client_authProviders_authCodeMsalBrowser.js?v=3372f56d:16845:27) at step (http://localhost:5173/node_modules/.vite/deps/chunk-QXXCRS6M.js?v=4882f8fb:208:17) at Object.next (http://localhost:5173/node_modules/.vite/deps/chunk-QXXCRS6M.js?v=4882f8fb:160:14) at http://localhost:5173/node_modules/.vite/deps/chunk-QXXCRS6M.js?v=4882f8fb:147:67 at new Promise (<anonymous>) at Object.__awaiter (http://localhost:5173/node_modules/.vite/deps/chunk-QXXCRS6M.js?v=4882f8fb:129:10) at AuthCodeMSALBrowserAuthenticationProvider2.getAccessToken (http://localhost:5173/node_modules/.vite/deps/@microsoft_microsoft-graph-client_authProviders_authCodeMsalBrowser.js?v=3372f56d:16838:26) at _AuthenticationHandler.<anonymous> (http://localhost:5173/node_modules/.vite/deps/@microsoft_microsoft-graph-client.js?v=8e109230:803:52) at Generator.next (<anonymous>)
stack
:
"Error\n at new GraphClientError2 (http://localhost:5173/node_modules/.vite/deps/@microsoft_microsoft-graph-client_authProviders_authCodeMsalBrowser.js?v=3372f56d:16797:30)\n at AuthCodeMSALBrowserAuthenticationProvider2.<anonymous> (http://localhost:5173/node_modules/.vite/deps/@microsoft_microsoft-graph-client_authProviders_authCodeMsalBrowser.js?v=3372f56d:16845:27)\n at step (http://localhost:5173/node_modules/.vite/deps/chunk-QXXCRS6M.js?v=4882f8fb:208:17)\n at Object.next (http://localhost:5173/node_modules/.vite/deps/chunk-QXXCRS6M.js?v=4882f8fb:160:14)\n at http://localhost:5173/node_modules/.vite/deps/chunk-QXXCRS6M.js?v=4882f8fb:147:67\n at new Promise (<anonymous>)\n at Object.__awaiter (http://localhost:5173/node_modules/.vite/deps/chunk-QXXCRS6M.js?v=4882f8fb:129:10)\n at AuthCodeMSALBrowserAuthenticationProvider2.getAccessToken (http://localhost:5173/node_modules/.vite/deps/@microsoft_microsoft-graph-client_authProviders_authCodeMsalBrowser.js?v=3372f56d:16838:26)\n at _AuthenticationHandler.<anonymous> (http://localhost:5173/node_modules/.vite/deps/@microsoft_microsoft-graph-client.js?v=8e109230:803:52)\n at Generator.next (<anonymous>)"
[[Prototype]]
:
Error
**error_1**
:
InteractionRequiredAuthError: invalid_grant: AADSTS65001: The user or administrator has not consented to use the application with ID 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' named 'xxxxx'. Send an interactive authorization request for this user and resource. Trace ID: a78c4369-1ba1-4643-9bc6-a41118743b00 Correlation ID: 01992398-5e93-72f1-97cb-19d935dc8e56 Timestamp: 2025-09-07 09:53:32Z at _ResponseHandler.validateTokenResponse (http://localhost:5173/node_modules/.vite/deps/chunk-PJPP7UDJ.js?v=4882f8fb:5595:15) at RefreshTokenClient.acquireToken (http://localhost:5173/node_modules/.vite/deps/chunk-PJPP7UDJ.js?v=4882f8fb:6052:21) at async RefreshTokenClient.acquireTokenWithCachedRefreshToken (http://localhost:5173/node_modules/.vite/deps/chunk-PJPP7UDJ.js?v=4882f8fb:6109:14)
claims
:
""
correlationId
:
"01992398-5eb9-7c07-9a34-c2a893c5371a"
errorCode
:
"invalid_grant"
errorMessage
:
"AADSTS65001: The user or administrator has not consented to use the application with ID 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' named 'xxxx'. Send an interactive authorization request for this user and resource. Trace ID: a78c4369-1ba1-4643-9bc6-a41118743b00 Correlation ID: 01992398-5e93-72f1-97cb-19d935dc8e56 Timestamp: 2025-09-07 09:53:32Z"
errorNo
:
65001
name
:
"InteractionRequiredAuthError"
subError
:
"consent_required"
timestamp
:
"2025-09-07 09:53:32Z"
traceId
:
"a78c4369-1ba1-4643-9bc6-a41118743b00"
message
:
"invalid_grant: AADSTS65001: The user or administrator has not consented to use the application with ID 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' named 'xxxx'. Send an interactive authorization request for this user and resource. Trace ID: a78c4369-1ba1-4643-9bc6-a41118743b00 Correlation ID: 01992398-5e93-72f1-97cb-19d935dc8e56 Timestamp: 2025-09-07 09:53:32Z"
stack
:
"InteractionRequiredAuthError: invalid_grant: AADSTS65001: The user or administrator has not consented to use the application with ID 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' named 'xxxx'. Send an interactive authorization request for this user and resource. Trace ID: a78c4369-1ba1-4643-9bc6-a41118743b00 Correlation ID: 01992398-5e93-72f1-97cb-19d935dc8e56 Timestamp: 2025-09-07 09:53:32Z\n at _ResponseHandler.validateTokenResponse (http://localhost:5173/node_modules/.vite/deps/chunk-PJPP7UDJ.js?v=4882f8fb:5595:15)\n at RefreshTokenClient.acquireToken (http://localhost:5173/node_modules/.vite/deps/chunk-PJPP7UDJ.js?v=4882f8fb:6052:21)\n at async RefreshTokenClient.acquireTokenWithCachedRefreshToken (http://localhost:5173/node_modules/.vite/deps/chunk-PJPP7UDJ.js?v=4882f8fb:6109:14)"
[[Prototype]]
:
_AuthError
- 主要语言
- TypeScript
- 星标
- 833
- 派生
- 240
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoftgraph/msgraph-sdk-javascript 的其他 Issue
-
status:waiting-for-triage
难度 1/5 1 小时以内 新手友好度 62/100
-
Is anyone here? 未关闭
难度 4/5 3-5 天 新手友好度 25/100
microsoftgraph/msgraph-sdk-javascript#2005 · 1 个 reaction ·
-
status:waiting-for-triage
难度 5/5 一周以上 新手友好度 42/100
-
status:waiting-for-triage type:bug
难度 3/5 1-2 天 新手友好度 48/100
microsoftgraph/msgraph-sdk-javascript#1999 · 2 条评论 · 1 个 reaction ·
-
status:waiting-for-triage type:bug
难度 4/5 3-5 天 新手友好度 45/100
查看 microsoftgraph/msgraph-sdk-javascript 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
-
check:passed streams:add
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 2/5 1-3 小时 新手友好度 76/100
-
难度 2/5 1-3 小时 新手友好度 68/100
-
usability
难度 2/5 1-3 小时 新手友好度 68/100
inmanta/web-console#7367 ·