ActiveDirectoryAuthenticationProvider.AcquireTokenAsync method fails when ConnectTimeout set to 0 or >= int.MaxValue/1000 #2563
Closed
Description
Well that was fun to debug!
As the ConnectionTimeout
is used to set the cancellation token's CancelAfter
* 1000...
- If
ConnectionTimeout = 0
then0 * 1000 = 0
- this causes the cancellation token to immediately expire, so all operations such as gather the tenant metadata fail withA task was canceled
exception message (which is what led me down this rabbit hole). - If
ConnectionTimeout = int.MaxValue
(or any value greater than int.MaxValue / 1000) thenint.MaxValue * 1000
throws as the result is larger than int.
Ideally this needs more defensive coding, eg:
- When
ConnectionTimeout == 0
we do not require aCancelAfter
? - When
ConnectionTimeout >= int.MaxValue / 1000
set theCancelAfter
toint.MaxValue
?
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Closed