This repository has been archived by the owner on Jan 19, 2021. It is now read-only.
How to connect any tenant SharePoint without credentials #2784
Unanswered
KaushalKhamar
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello
I want to create 1 product for sharepoint online assessment which is Web bases and having the Windows authentication
So how can i connect SharePoint without credential of any tenant from the web application?
I had tried it using Windows authentication and from that i get the access token but that access token does not work in Azure function for getting the sharepoint connection in azure function
I had used below code to get the access token in web site
string userObjectID = (User.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier"))?.Value;
AuthenticationContext authContext = new AuthenticationContext("https://login.windows.net/1a86a77c-9af1-47b4-980b-03ef62f12e63/oauth2/authorize", new NaiveSessionCache(userObjectID, HttpContext.Session));
ClientCredential credential = new ClientCredential(AzureAdOptions.Settings.ClientId, AzureAdOptions.Settings.ClientSecret);
result = await authContext.AcquireTokenSilentAsync("https://graph.microsoft.com", credential, new UserIdentifier(userObjectID, UserIdentifierType.UniqueId));
//Calling Azure Function
HttpClient _client = new HttpClient();
HttpRequestMessage newRequest = new HttpRequestMessage(HttpMethod.Get, "https://onlineassessment.azurewebsites.net/api/HttpTriggerPowerShell1?code=4gmK34HVbXdAkoa5jgo9kSA1y6OaIy1kTWg1gQhCeSa/Ka1G7vKFsg==&name=" + result.AccessToken);
HttpResponseMessage response1 = await _client.SendAsync(newRequest);
Beta Was this translation helpful? Give feedback.
All reactions