feat: Implement initial token-based authentication flow #332
+3,043
−69
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
feat: Implement initial token-based authentication flow
This commit introduces changes to allow the IntuneManagement tool to utilize a pre-acquired bearer token for authentication, aiming to bypass standard App ID/Secret or interactive login methods.
Modifications include:
Fix: Prioritize pre-acquired token and prevent re-authentication
This commit addresses an issue where the interactive login prompt was incorrectly triggered even when a pre-acquired bearer token was provided.
The following changes were made:
Invoke-GraphRequest
inExtensions/MSGraph.psm1
to check for a valid existing$global:MSALToken
(not expired) before attempting to callConnect-MSALUser
. This prevents unnecessary re-authentication attempts.Connect-MSALUser
inExtensions/MSALAuthentication.psm1
to include an early return if$global:MSALToken
exists, is derived from$global:RawAccessToken
, and is not expired. This ensures that if a valid token has been set via theAccessToken
parameter, the function will not proceed with further (interactive) authentication steps.These changes ensure that the token-based authentication flow is correctly prioritized, preventing the interactive login from appearing when a valid token is already available.