-
Notifications
You must be signed in to change notification settings - Fork 172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No Authentication Prompt for connect-mggraph #3034
Comments
From my experience using the Microsoft.Graph.* modules, I've seen that If you perform Connect-MgGraph, then close the powershell window it was run from, or reboot, or even hibernate a laptop that window is in, or perhaps other actions that can interrupt the current "session", subsequent calls to Connect-MgGraph will use some type of cached credentials from the last credential-prompted invocation of Connect-MgGraph. Calls to Get-MgContext will NOT show this cached credential state either, it only seems to return data on an established session. This cache persists across reboots as well, and seems to me to be a security risk. I'd love to see some additional functionality added to these commands:
A current partial work-around I use is to pre-define $DevTenantId and $ProdTenantId in my $PROFILE so I can at least deterministicaly connect to the correct TENANT regardless the state of any cached credentials Connect-MgGraph might use, but even that's not a complete solution, since it's possible to connect with accounts of different levels of privilege (read-only, limited admin, global admin) and specifying the tenant ID won't help if the previous connection cached an account with higher privileges than I want to use this time. |
Did you found a way to solve that or at least a workaround? |
The closest I have to a work-around is to do a Connect-MgGraph - if not prompted, then Disconnect-MgGraph followed by a Connect-MgGraph which WILL prompt. I've heard about the new EntraID powershell module - purported to be closer in functionality to the depreciated AzureAD module - I thought it was still in preview and/or based on Beta Graph API endpoints, so I haven't tried it yet, but I plan to at some point soon. |
@pedrr thank you for logging this issue. I would like to know your experience when you restart the PowerShell session and try to execute the command again. |
I tried to run the command in an own terminal windows and run it in VSCode. The issue can be resolved sometimes if I restart my client, don't open any edge browser and immediatly try to run the command. |
Describe the bug
I try to use the normal authentication with connect-mggraph but the Authentication Prompt does not show, (the browser, nor the webview2)
$PSVersionTable
Name Value
PSVersion 7.4.6
PSEdition Core
GitCommitId 7.4.6
OS Microsoft Windows 10.0.26100
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Expected behavior
I shall show some authentication prompt
How to reproduce
run connect-mggraph
SDK Version
No response
Latest version known to work for scenario above?
No response
Known Workarounds
No response
Debug output
oduleType Version PreRelease Name ExportedCommands
Script 2.24.0 Microsoft.Graph.Authentication {Add-MgEnvironment, Connect-MgGraph, Disconnect-MgGraph, Get-MgContext…}
Manifest 7.0.0.0 Microsoft.PowerShell.Management {Add-Content, Clear-Content, Clear-Item, Clear-ItemProperty…}
Manifest 7.0.0.0 Microsoft.PowerShell.Security {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl, Get-AuthenticodeSignature…}
Manifest 7.0.0.0 Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable, Compare-Object…}
Script 0.2.0 PowerShellEditorServices.Commands {Clear-Host, ConvertFrom-ScriptExtent, ConvertTo-ScriptExtent, Find-Ast…}
Script 2.4.0 beta0 PSReadLine {Get-PSReadLineKeyHandler, Get-PSReadLineOption, Remove-PSReadLineKeyHandler, Set-PSReadLineKeyHandler…}
Configuration
No response
Other information
DEBUG: DeviceCodeCredential.Authenticate invoked. Scopes: [ User.Read ] ParentRequestId:
DEBUG: False MSAL 4.61.3.0 MSAL.NetCore .NET 8.0.10 Microsoft Windows 10.0.26100 [2024-11-20 13:03:10Z - 3d912935-43cd-4787-874f-07e3b48317ca] MSAL MSAL.NetCore with assembly version '4.61.3.0'. CorrelationId(3d912935-43cd-4787-874f-07e3b48317ca)
DEBUG: False MSAL 4.61.3.0 MSAL.NetCore .NET 8.0.10 Microsoft Windows 10.0.26100 [2024-11-20 13:03:10Z - 3d912935-43cd-4787-874f-07e3b48317ca]
=== Request Data ===
Authority Provided? - True
Scopes - User.Read
Extra Query Params Keys (space separated) -
ApiId - AcquireTokenByDeviceCode
IsConfidentialClient - False
SendX5C - False
LoginHint ? False
IsBrokerConfigured - False
HomeAccountId - False
CorrelationId - 3d912935-43cd-4787-874f-07e3b48317ca
UserAssertion set: False
LongRunningOboCacheKey set: False
Region configured:
DEBUG: False MSAL 4.61.3.0 MSAL.NetCore .NET 8.0.10 Microsoft Windows 10.0.26100 [2024-11-20 13:03:10Z - 3d912935-43cd-4787-874f-07e3b48317ca] === Token Acquisition (DeviceCodeRequest) started:
Scopes: User.Read
Authority Host: login.microsoftonline.com
DEBUG: False MSAL 4.61.3.0 MSAL.NetCore .NET 8.0.10 Microsoft Windows 10.0.26100 [2024-11-20 13:03:10Z - 3d912935-43cd-4787-874f-07e3b48317ca] [Instance Discovery] Instance discovery is enabled and will be performed
DEBUG: False MSAL 4.61.3.0 MSAL.NetCore .NET 8.0.10 Microsoft Windows 10.0.26100 [2024-11-20 13:03:10Z - 3d912935-43cd-4787-874f-07e3b48317ca] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.61.3.0 MSAL.NetCore .NET 8.0.10 Microsoft Windows 10.0.26100 [2024-11-20 13:03:10Z - 3d912935-43cd-4787-874f-07e3b48317ca] Fetching instance discovery from the network from host login.microsoftonline.com.
DEBUG: Request [5db5c174-55dd-42cd-a92a-706f012b2083] GET https://login.microsoftonline.com/common/discovery/instance?api-version=1.1&authorization_endpoint=REDACTED
x-client-SKU:REDACTED
x-client-Ver:REDACTED
x-client-OS:REDACTED
client-request-id:REDACTED
return-client-request-id:REDACTED
x-app-name:REDACTED
x-app-ver:REDACTED
x-ms-client-request-id:5db5c174-55dd-42cd-a92a-706f012b2083
x-ms-return-client-request-id:true
User-Agent:azsdk-net-Identity/1.11.4 (.NET 8.0.10; Microsoft Windows 10.0.26100)
client assembly: Azure.Identity
The text was updated successfully, but these errors were encountered: