Skip to content

Instantly share code, notes, and snippets.

@anaselhajjaji
Last active April 3, 2017 21:51
Show Gist options
  • Save anaselhajjaji/15208f410ed65311ce4ed3078ff42224 to your computer and use it in GitHub Desktop.
Save anaselhajjaji/15208f410ed65311ce4ed3078ff42224 to your computer and use it in GitHub Desktop.
Button adalButton = FindViewById<Button>(Resource.Id.adalButton);
adalButton.Click += async (sender, args) =>
{
var authContext = new AuthenticationContext(commonAuthority);
if (authContext.TokenCache.ReadItems().Count() > 0)
{
authContext = new AuthenticationContext(authContext.TokenCache.ReadItems().First().Authority);
}
authResult = await authContext.AcquireTokenAsync(graphResourceUri, clientId, returnUri, new PlatformParameters(this));
if ((authResult != null) && !string.IsNullOrEmpty(authResult.AccessToken))
{
Toast.MakeText(this, string.Format("Welcome {0} {1}.", authResult.UserInfo.GivenName,
authResult.UserInfo.FamilyName), ToastLength.Long).Show();
StartActivity(typeof(RememberListActivity));
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment