Usage - Xablu/Xablu.ADAL GitHub Wiki

The Xablu ADAL component needs a valid configuration in order to start the login process. This configuration has to be provided before any login validation can take place. Best practice is to provide it during your app start:

CrossAdal.Current.Configure(new AdalConfiguration
{
    //authentication context to connect to for retrieving a token
    "https://login.microsoftonline.com/mytenant.onmicrosoft.com",

    // client that is asking for access
    "7226D655-D555-44C9-A22F-07F7C6C31F9C",

    // uri where the user is redirected after successful login
    new Uri("https://myapp.myorg.com"),

    // requested resource to gain access to
    "https://myresource.myorg.com/"
});

Of course, this example configuration is not going to work so make sure to replace these values with the correct values for your own Azure environment.

At any place in your app, you can now request the ADAL component to ensure that a valid user is logged in:

var user = await CrossAdal.Current.EnsureUserLoggedIn();

This call will show the login page, allowing the user to enter and validate his credentials. If the provided login credentials are correct, the method returns an object with relevant information about the user that sucessfully logged in. If the user enters incorrect credentials, a warning message is shown inside the webview. If the user cancels the login or some other situation causes the login view to exit before a successful login, the CrossAdal.Current.EnsureUserLoggedIn method will throw a specific exception explaining why the login was unsuccessful.