Instantly share code, notes, and snippets.

Embed
What would you like to do?
Connect to Azure AD in Azure Function
string TenantID = <TenantID>;
string authString = "https://login.windows.net/" + TenantID;
string SPServiceUrl = "https://manage.office.com/api/v1.0/" + TenantID + "/activity/feed/subscriptions/content";
string resourceId = "https://manage.office.com";
string clientId = <Client App Id>;
string clientSecret = <Client App secret>;
ClientCredential clientCred = new ClientCredential(clientId, clientSecret);
AuthenticationResult authenticationResult = null;
Task runTask = Task.Run(async () => authenticationResult = await authenticationContext.AcquireTokenAsync(resourceId, clientCred));
runTask.Wait();
string token = authenticationResult.AccessToken;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment