public static async Task <string> GetVideoPortalRootUrl() { if (string.IsNullOrEmpty(_videoPortalRootUrl)) { HttpClient client = new HttpClient(); client.DefaultRequestHeaders.Add("Accept", "application/json;odata=verbose"); client.DefaultRequestHeaders.Add("Authorization", "Bearer " + await AadHelper.GetAccessTokenForSharePoint()); // create request to video portal's discovery endpoint var query = string.Format("https://{0}.sharepoint.com/_api/VideoService.Discover", SettingsHelper.Office365TenantId); // issue request & get response var response = await client.GetAsync(query); string responseString = await response.Content.ReadAsStringAsync(); // convert response to object var jsonResponse = JsonConvert.DeserializeObject <VideoServiceDiscovery>(responseString); _videoPortalRootUrl = jsonResponse.Data.VideoPortalUrl; } return(_videoPortalRootUrl); }
public static GraphServiceClient GetAuthenticatedClient(string userObjectId) { GraphServiceClient graphClient = new GraphServiceClient(//"https://graph.microsoft.com/beta", new DelegateAuthenticationProvider( async(requestMessage) => { string accessToken = //await SampleAuthProvider.Instance.GetUserAccessTokenAsync(); await AadHelper.GetAccessTokenFromGraphRefreshTokenAsync(userObjectId); // Append the access token to the request. requestMessage.Headers.Authorization = new AuthenticationHeaderValue("bearer", accessToken); // This header has been added to identify our sample in the Microsoft Graph service. If extracting this code for your project please remove. //requestMessage.Headers.Add("SampleID", "aspnet-connect-sample"); })); return(graphClient); }