Created
August 5, 2022 11:01
-
-
Save cobysy/2cefda807a83bd845d6f0868b2e20630 to your computer and use it in GitHub Desktop.
PublicClientApplicationBuilder - get token for current user msal.net
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
var result = await PublicClientApplicationBuilder.CreateWithApplicationOptions(options: new() | |
{ | |
ClientId = "8bxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", | |
TenantId = "1exxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" | |
}) | |
.WithRedirectUri(redirectUri: "http://localhost") | |
.Build() | |
.AcquireTokenInteractive(scopes: "api://7fxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/some.web.api openid profile offline_access".Split(separator: ' ')) | |
.WithAccount(account: PublicClientApplication.OperatingSystemAccount) | |
.WithPrompt(prompt: Prompt.NoPrompt) | |
.WithExtraHttpHeaders(extraHttpHeaders: new Dictionary<string, string> | |
{ | |
{"Origin", "http://localhost"} | |
}) | |
.ExecuteAsync(); | |
return result; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment