Esempio n. 1
0
        public static JObject GetTokenForResourceFromCode(AzureTokenRequestMeta meta, string tenantId, string redirect, string code)
        {
            JObject tokenObj;

            using (HttpClient httpClient = new HttpClient())
            {
                string        tokenUrl = string.Format(Constants.AzureTokenUri, tenantId);
                string        token    = AzureTokenUtility.GetTokenBodyFromCode(code, meta.Resource, redirect, meta.ClientId);
                StringContent content  = new StringContent(token);
                content.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");
                string response2 = httpClient.PostAsync(new Uri(tokenUrl), content).Result.Content.AsString();
                tokenObj = JsonUtility.GetJsonObjectFromJsonString(response2);
            }

            return(tokenObj);
        }
Esempio n. 2
0
        public static JObject GetTokenForResourceFromCode(string resource, string client, string tenantId, string redirect, string code)
        {
            var meta = new AzureTokenRequestMeta(resource, client);

            return(GetTokenForResourceFromCode(meta, tenantId, redirect, code));
        }