static async Task <GraphInfo> GetCDAGraphInfo(HttpRequestMessage req, TraceWriter log) { GraphInfo cdaInfo = null; try { // Using the passed in token from the mobile app (which will authenticate against the MSFT corp AD) - call the MS Graph to get user info if (!req.Headers.Authorization.Scheme.Equals("bearer", StringComparison.OrdinalIgnoreCase) && !string.IsNullOrWhiteSpace(req.Headers.Authorization.Parameter)) { return(null); } var token = req.Headers.Authorization.Parameter; var graphReqMsg = new HttpRequestMessage(HttpMethod.Get, "https://graph.microsoft.com/v1.0/me"); graphReqMsg.Headers.Authorization = new AuthenticationHeaderValue("bearer", token); var graphResponse = await httpClient.SendAsync(graphReqMsg); cdaInfo = GraphInfo.FromJson(await graphResponse.Content.ReadAsStringAsync()); if (string.IsNullOrWhiteSpace(cdaInfo.UserPrincipalName)) { return(null); } log.Info(cdaInfo.ToString()); } catch (Exception ex) { log.Error("Graph HTTP call", ex); return(null); } return(cdaInfo); }