Last active
May 29, 2020 21:12
-
-
Save manoj-choudhari-git/1137bda0f76766b06082916fe4fc6d95 to your computer and use it in GitHub Desktop.
Azure AD Authentication in WPF Application using MSAL
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
public partial class App : Application | |
{ | |
private static string ClientId = "89866898-d443-442e-ad58-21b6b308a520"; | |
private static string Tenant = "da41245a5-11b3-996c-00a8-4d99re19f292"; | |
private static string Instance = "https://login.microsoftonline.com/"; | |
public static IPublicClientApplication PublicClientApp { get; private set; } | |
static App() | |
{ | |
PublicClientApp = PublicClientApplicationBuilder.Create(ClientId) | |
.WithAuthority($"{Instance}{Tenant}") | |
.WithRedirectUri("http://localhost") | |
.Build(); | |
TokenCacheHelper.Bind(PublicClientApp.UserTokenCache); | |
} | |
private static void Log(LogLevel level, string message, bool containsPii) | |
{ | |
string logs = ($"{level} {message}"); | |
StringBuilder sb = new StringBuilder(); | |
sb.Append(logs); | |
File.AppendAllText(System.Reflection.Assembly.GetExecutingAssembly().Location + ".msalLogs.txt", sb.ToString()); | |
sb.Clear(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment