// Token: 0x0600020F RID: 527 RVA: 0x000081AC File Offset: 0x000063AC internal static DownloadResult SendRestRequest(string requestMethod, string requestUri, OwaIdentity identity, Stream requestStream, DataProviderCallLogEvent logEvent, string spCallName) { DownloadResult result; using (HttpClient httpClient = new HttpClient()) { HttpSessionConfig httpSessionConfig = new HttpSessionConfig { Method = requestMethod, Credentials = OauthUtils.GetOauthCredential(identity.GetOWAMiniRecipient()), UserAgent = OneDriveProUtilities.UserAgentString, RequestStream = requestStream, ContentType = "application/json;odata=verbose", PreAuthenticate = true }; httpSessionConfig.Headers = OneDriveProUtilities.GetOAuthRequestHeaders(); if (logEvent != null) { logEvent.TrackSPCallBegin(); } ICancelableAsyncResult cancelableAsyncResult = httpClient.BeginDownload(new Uri(requestUri), httpSessionConfig, null, null); cancelableAsyncResult.AsyncWaitHandle.WaitOne(); DownloadResult downloadResult = httpClient.EndDownload(cancelableAsyncResult); if (logEvent != null) { string correlationId = (downloadResult.ResponseHeaders == null) ? null : downloadResult.ResponseHeaders["SPRequestGuid"]; logEvent.TrackSPCallEnd(spCallName, correlationId); } result = downloadResult; } return(result); }
// Token: 0x0600020D RID: 525 RVA: 0x00008150 File Offset: 0x00006350 internal static IClientContext CreateAndConfigureClientContext(OwaIdentity identity, string url) { ICredentials oneDriveProCredentials = OneDriveProUtilities.GetOneDriveProCredentials(identity); IClientContext clientContext = ClientContextFactory.Create(url); clientContext.Credentials = oneDriveProCredentials; clientContext.FormDigestHandlingEnabled = false; clientContext.ExecutingWebRequest += delegate(object sender, WebRequestEventArgs args) { if (args != null) { args.WebRequestExecutor.RequestHeaders.Add(OneDriveProUtilities.GetOAuthRequestHeaders()); args.WebRequestExecutor.WebRequest.PreAuthenticate = true; args.WebRequestExecutor.WebRequest.UserAgent = OneDriveProUtilities.UserAgentString; } }; return(clientContext); }
// Token: 0x06000211 RID: 529 RVA: 0x000082BC File Offset: 0x000064BC internal static string GetWacUrl(OwaIdentity identity, string endPointUrl, string documentUrl, bool isEdit) { string arg = isEdit ? "2" : "4"; string text = string.Format("{0}/_api/Microsoft.SharePoint.Yammer.WACAPI.GetWacToken(fileUrl=@p, wopiAction={2})?@p='{1}'", endPointUrl, documentUrl, arg); string result; using (HttpClient httpClient = new HttpClient()) { OWAMiniRecipient owaminiRecipient = identity.GetOWAMiniRecipient(); ICredentials oauthCredential = OauthUtils.GetOauthCredential(owaminiRecipient); WebHeaderCollection oauthRequestHeaders = OneDriveProUtilities.GetOAuthRequestHeaders(); HttpSessionConfig sessionConfig = new HttpSessionConfig { Method = "GET", Credentials = oauthCredential, UserAgent = OneDriveProUtilities.UserAgentString, ContentType = "application/json;odata=verbose", PreAuthenticate = true, Headers = oauthRequestHeaders }; DownloadResult downloadResult; try { downloadResult = OneDriveProUtilities.TryTwice(httpClient, sessionConfig, text); } catch (WebException ex) { if (!OneDriveProUtilities.IsDurableUrlFormat(documentUrl)) { throw ex; } ExTraceGlobals.AttachmentHandlingTracer.TraceWarning <string>(0L, "OneDriveProUtilities.GetWacUrl Exception while trying to get wac token using durable url. : {0}", ex.StackTrace); documentUrl = documentUrl.Substring(0, documentUrl.LastIndexOf("?", StringComparison.InvariantCulture)); text = string.Format("{0}/_api/Microsoft.SharePoint.Yammer.WACAPI.GetWacToken(fileUrl=@p, wopiAction={2})?@p='{1}'", endPointUrl, documentUrl, arg); ExTraceGlobals.AttachmentHandlingTracer.TraceWarning <string>(0L, "OneDriveProUtilities.GetWacUrl Fallback to canonical url format: {0}", text); OwaServerTraceLogger.AppendToLog(new TraceLogEvent("SP.GWT", null, "GetWacToken", string.Format("Error getting WAC Token fallback to canonical format:{0}", text))); downloadResult = OneDriveProUtilities.TryTwice(httpClient, sessionConfig, text); } XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(downloadResult.ResponseStream); string namespaceURI = "http://schemas.microsoft.com/ado/2007/08/dataservices"; string text2 = null; string text3 = null; string text4 = null; foreach (object obj in xmlDocument.GetElementsByTagName("*", namespaceURI)) { XmlNode xmlNode = (XmlNode)obj; if (xmlNode is XmlElement) { if (text2 != null && text3 != null && text4 != null) { break; } if (string.CompareOrdinal(xmlNode.LocalName, "AppUrl") == 0) { text2 = xmlNode.InnerText; } else if (string.CompareOrdinal(xmlNode.LocalName, "AccessToken") == 0) { text3 = xmlNode.InnerText; } else if (string.CompareOrdinal(xmlNode.LocalName, "AccessTokenTtl") == 0) { text4 = xmlNode.InnerText; } } } if (text2 == null || text3 == null || text4 == null) { throw new OwaException("SharePoint's GetWacToken response is not usable."); } string text5 = isEdit ? "OwaEdit" : "OwaView"; result = string.Format("{0}&access_token={1}&access_token_ttl={2}&sc={3}", new object[] { text2, text3, text4, text5 }); } return(result); }