Skip to content

Instantly share code, notes, and snippets.

@TBag
Created March 2, 2015 16:38
Show Gist options
  • Select an option

  • Save TBag/94fbe8d843c1eefbb1f0 to your computer and use it in GitHub Desktop.

Select an option

Save TBag/94fbe8d843c1eefbb1f0 to your computer and use it in GitHub Desktop.
GetActiveDirectoryClientmethod from Property Inspection Code Sample. Part of the AuthenticationHelper class found here: https://github.com/OfficeDev/Property-Inspection-Code-Sample/blob/master/PropertyManagerMyApp/PropertyManagerMyApp/Utils/AuthenticationHelper.cs
private async Task<ActiveDirectoryClient> GetActiveDirectoryClient()
{
Uri baseServiceUri = new Uri(AADAppSettings.AADGraphResourceId);
var tenantId = ClaimsPrincipal.Current.FindFirst("http://schemas.microsoft.com/identity/claims/tenantid").Value;
ActiveDirectoryClient activeDirectoryClient =
new ActiveDirectoryClient(new Uri(baseServiceUri, tenantId),
async () => await AcquireTokenAsync());
return activeDirectoryClient;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment