GraphAPI Token
 public async Task<string> getAuthorizationCode()
        {
            // Get a token for calling the Windows Azure Active Directory Graph
            AuthenticationContext authContext = new AuthenticationContext(String.Format(CultureInfo.InvariantCulture, GraphConfiguration.loginURL, GraphConfiguration.tenantId));
            ClientCredential credential = new ClientCredential(GraphConfiguration.clientId, GraphConfiguration.api_key);
            AuthenticationResult assertionCredential = authContext.AcquireToken(GraphConfiguration.graphResourceId, credential);
            return assertionCredential.AccessToken;
            /*
            string authHeader = assertionCredential.CreateAuthorizationHeader();
            string requestUrl = String.Format(
                CultureInfo.InvariantCulture,
                "https://graph.windows.net",
                HttpUtility.UrlEncode(GraphConfiguration.tenantId),
                HttpUtility.UrlEncode("santosh.raghavan@cmc.com"));

            HttpClient client = new HttpClient();
            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUrl);
            request.Headers.TryAddWithoutValidation("Authorization", authHeader);
            HttpResponseMessage response = await client.SendAsync(request);
            string responseString = await response.Content.ReadAsStringAsync();
            return responseString;
            */
        }
namespace CMCGraphAPITest.Utils
{
    public class GraphConfiguration
    {
        public static string graphResourceId = "https://graph.windows.net";
        public static string graphApiVersion = "2013-04-05";
        public static string tenantIdClaimType = "http://schemas.microsoft.com/identity/claims/tenantid";
        public static string tenantId = "37d9c6c0-52b0-4aa7-a49f-ccddfffgdds433";
        public static string loginURL = "https://login.windows.net/commercialmetalscompany.onmicrosoft.com";
        public static string clientId = "f061fd2a-2292-4f29-be55-6e8085333ab0";
        public static string api_key = "qtqDo3oGNnSNkxhjf+LMO+gDNasquPgpkkkkyCrU8=";
    }
}
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License