-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add web account manager (WAM) support (#436)
chore: remove redundant attribute fix: add default scopes to solve login error when no scopes are provided ci: fixes test failure chore: remove redundant SupportedOSPlatform attribute
- Loading branch information
1 parent
e7d7682
commit a5fe538
Showing
6 changed files
with
73 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
using System.Runtime.Versioning; | ||
|
||
namespace Microsoft.Graph.Cli.Core.utils; | ||
|
||
[SupportedOSPlatform("Windows")] | ||
internal partial class WindowUtils | ||
{ | ||
enum GetAncestorFlags | ||
{ | ||
GetParent = 1, | ||
GetRoot = 2, | ||
/// <summary> | ||
/// Retrieves the owned root window by walking the chain of parent and owner windows returned by GetParent. | ||
/// </summary> | ||
GetRootOwner = 3 | ||
} | ||
|
||
/// <summary> | ||
/// Retrieves the handle to the ancestor of the specified window. | ||
/// </summary> | ||
/// <param name="hwnd">A handle to the window whose ancestor is to be retrieved. | ||
/// If this parameter is the desktop window, the function returns NULL. </param> | ||
/// <param name="flags">The ancestor to be retrieved.</param> | ||
/// <returns>The return value is the handle to the ancestor window.</returns> | ||
[LibraryImport("user32.dll")] | ||
private static partial IntPtr GetAncestor(IntPtr hwnd, GetAncestorFlags flags); | ||
|
||
[LibraryImport("kernel32.dll")] | ||
private static partial IntPtr GetConsoleWindow(); | ||
|
||
// https://learn.microsoft.com/en-us/entra/msal/dotnet/acquiring-tokens/desktop-mobile/wam#parent-window-handles | ||
internal static IntPtr GetConsoleOrTerminalWindow() | ||
{ | ||
var consoleHandle = GetConsoleWindow(); | ||
var handle = GetAncestor(consoleHandle, GetAncestorFlags.GetRootOwner); | ||
return handle; | ||
} | ||
} |