Closed TiagoBrenck closed 4 years ago
Thanks @TiagoBrenck . MSAL does not support this flow for ADFS authority, but it should throw a nice exception (also for B2C authority)
FYI @kalyankrishna1
Thanks @bgavrilMS
By design
Why is this flow not supported in ADFS Authority? What is the recommended alternative for users federated via ADFS?
Experiencing a similar issue. Could someone post the technique we should be using instead?
Given that there is a parameter ".WithAdfsAuthority" and that documentation says to use MSAL for Windows Domain and Azure Domain, and that it says Windows Server 2019 required with local ADFS... then I thought this would work (is this the same problem as the above posting? I get the same error message about unexpected character):
public class Authenticate
{
public static async Task<string> GetOpenIdToken()
{
string ADFSBaseAddress = "https://dc.internal.net/adfs";
string ClientID = "12a112a1-12a1-12a1-12a1-12a112a112a1";
string RedirectUri = "xyz.setupinadfs.app://";
string token = string.Empty;
PublicClientApplicationBuilder builder = PublicClientApplicationBuilder.Create(ClientID);
builder.WithAdfsAuthority(ADFSBaseAddress);
builder.WithRedirectUri(RedirectUri);
IPublicClientApplication app = builder.Build();
var accounts = await app.GetAccountsAsync();
string[] scopes = new string[] { "openid", "profile" };
AuthenticationResult result = null;
if (accounts.Any())
{
AcquireTokenSilentParameterBuilder paramBuilder;
paramBuilder = app.AcquireTokenSilent(scopes, accounts.FirstOrDefault());
result = await paramBuilder.ExecuteAsync();
token = result.AccessToken;
}
else
{
try
{
AcquireTokenByIntegratedWindowsAuthParameterBuilder paramBuilder;
paramBuilder = app.AcquireTokenByIntegratedWindowsAuth(scopes);
result = await paramBuilder.ExecuteAsync();
token = result.AccessToken;
}
catch (Exception e)
{
Console.WriteLine("msal: " + e.Message);
}
}
return token;
}
}
Which Version of MSAL are you using ? MSAL 4.17.1
Platform net 4.7.2
What authentication flow has the issue?
Other? - please describe; This is inside an ADFS environment
Is this a new or existing app? c. This is a new app or experiment
Repro On an ADFS environment VM, run the code:
Expected behavior Acquire the access token with
user_impersonation
scopeActual behavior Error:
Unexpected character encountered while parsing value: <. Path '', line 1, position 1.
Possible Solution
Additional context/ Logs / Screenshots