SSO Authentication Default Browser and Account
Background
I have a script that authenticate me through my Azure. This is really a single sign on auth to acquire STS token where LINQPad would show a browser for me to login. See the code below.
Issue and Attempt
I think the issue might have bee with the embedded web view in Linqpad. It is always default to a certain account and there's no way to clear cookies on this web view.
I also think this somewhat has to do with Windows Authentication. Whenever I'm on my corporate network, it default the login to my corporate account. The web view seems to pick up my Windows Authentication, thus, use the corporate account as default. This makes me suspect that LinqPad is using IE as the web view.
Similarly, in PowerShell, I can run `Login-AzureRmAccount` command, it would authenticate through SSO to acquire STS token. If I'm on the corporate network, PowerShell will also default to my corporate account. However, when I get off corporate network, it no longer default to corporate account.
The Ask.
Is there a way to specify browser to use for the web view? Or, is there a way to clear the cookies in that web view (not that I think it'd help since it's defaulting to my corporate account)?
Code
This is my code to authenticate with Azure
var aadInstance = "https://login.windows.net/{0}";
var resourceId = "https://someresource.windows.net/";
var aadTenantId = "";
var aadLinqpadClientId = "";
var aadLinqpadClientRedirectUri = "";
// Authenticate with Azure AD
AuthenticationContext authenticationContext;
if (TokenCache != null)
authenticationContext = new AuthenticationContext(string.Format(aadInstance, aadTenantId), TokenCache);
else
authenticationContext = new AuthenticationContext(string.Format(aadInstance, aadTenantId));
var authenticationResult = authenticationContext.AcquireTokenAsync(resourceId, aadLinqpadClientId, new Uri(aadLinqpadClientRedirectUri), new PlatformParameters(PromptBehavior.Auto)).Result;
if (authenticationResult == null)
throw new InvalidOperationException("Failed to obtain token");
return authenticationResult;
Any help would be appreciate it. Thanks!
I have a script that authenticate me through my Azure. This is really a single sign on auth to acquire STS token where LINQPad would show a browser for me to login. See the code below.
Issue and Attempt
I think the issue might have bee with the embedded web view in Linqpad. It is always default to a certain account and there's no way to clear cookies on this web view.
I also think this somewhat has to do with Windows Authentication. Whenever I'm on my corporate network, it default the login to my corporate account. The web view seems to pick up my Windows Authentication, thus, use the corporate account as default. This makes me suspect that LinqPad is using IE as the web view.
Similarly, in PowerShell, I can run `Login-AzureRmAccount` command, it would authenticate through SSO to acquire STS token. If I'm on the corporate network, PowerShell will also default to my corporate account. However, when I get off corporate network, it no longer default to corporate account.
The Ask.
Is there a way to specify browser to use for the web view? Or, is there a way to clear the cookies in that web view (not that I think it'd help since it's defaulting to my corporate account)?
Code
This is my code to authenticate with Azure
var aadInstance = "https://login.windows.net/{0}";
var resourceId = "https://someresource.windows.net/";
var aadTenantId = "";
var aadLinqpadClientId = "";
var aadLinqpadClientRedirectUri = "";
// Authenticate with Azure AD
AuthenticationContext authenticationContext;
if (TokenCache != null)
authenticationContext = new AuthenticationContext(string.Format(aadInstance, aadTenantId), TokenCache);
else
authenticationContext = new AuthenticationContext(string.Format(aadInstance, aadTenantId));
var authenticationResult = authenticationContext.AcquireTokenAsync(resourceId, aadLinqpadClientId, new Uri(aadLinqpadClientRedirectUri), new PlatformParameters(PromptBehavior.Auto)).Result;
if (authenticationResult == null)
throw new InvalidOperationException("Failed to obtain token");
return authenticationResult;
Any help would be appreciate it. Thanks!
Comments