J'essaye d'authentifier mon application en utilisant ADFS et oauth2. J'ai trouvé beaucoup de documentation pour le faire avec un service azur (en utilisant ADAL). Mais il n'y a pas d'informations sur la façon de le faire avec un serveur local.Xamarin: Création d'un client ADFS (Oauth2) sans azure
J'ai testé toutes les informations ci-dessous avec une application angulaire et l'authentification fonctionne!
public class AuthenticationService
{
public static string clientId = "uri:tst-amdm-website.mycompany.be";
private static string commonAuthority = "https://claim.mycompany.be/";
public static Uri returnUri = new Uri("http://www.google.be");
const string graphResourceUri = "uri:tst-amdm-api.mycompany.be";
public async void GetAccessToken(IPlatformParameters platformParameters)
{
AuthenticationResult authResult = null;
JObject jResult = null;
//List<User> results = new List<User>();
try
{
AuthenticationContext authContext = new AuthenticationContext(commonAuthority);
if (authContext.TokenCache.ReadItems().Any())
authContext = new AuthenticationContext(authContext.TokenCache.ReadItems().First().Authority);
authResult = await authContext.AcquireTokenAsync(graphResourceUri, clientId, returnUri, platformParameters);
var test = authResult.AccessToken;
}
catch (Exception ee)
{
//results.Add(new User { error = ee.Message });
//return results;
}
}
}
C'est l'erreur que je reçois, mais dans cette url angulaire: https://claim.mycompany.be/
fonctionne parfaitement.
'authority' Uri should have at least one segment in the path (i.e. https://<host>/<path>/...)