Esempio n. 1
0
        private async Task <string> GetLabResponseAsync(string address)
        {
            if (String.IsNullOrWhiteSpace(_labApiAccessToken))
            {
                _labApiAccessToken = await LabAuthenticationHelper.GetAccessTokenForLabAPIAsync(_labAccessAppId, _labAccessClientSecret).ConfigureAwait(false);
            }

            using (HttpClient httpClient = new HttpClient())
            {
                httpClient.DefaultRequestHeaders.Add("Authorization", string.Format(CultureInfo.InvariantCulture, "bearer {0}", _labApiAccessToken));
                return(await httpClient.GetStringAsync(address).ConfigureAwait(false));
            }
        }
        private async Task <string> SendLabRequestAsync(string requestUrl, IDictionary <string, string> queryDict)
        {
            UriBuilder uriBuilder = new UriBuilder(requestUrl)
            {
                Query = string.Join("&", queryDict.Select(x => x.Key + "=" + x.Value.ToString()))
            };

            var res = await LabAuthenticationHelper.GetAccessTokenForLabAPIAsync(_labAccessAppId, _labAccessClientSecret).ConfigureAwait(false);

            using (HttpClient httpClient = new HttpClient())
            {
                httpClient.DefaultRequestHeaders.Add("Authorization", string.Format(CultureInfo.InvariantCulture, "bearer {0}", res));
                return(await httpClient.GetStringAsync(uriBuilder.ToString()).ConfigureAwait(false));
            }
        }
Esempio n. 3
0
 private async Task <string> AuthenticationCallbackAsync(string authority, string resource, string scope)
 {
     return(await LabAuthenticationHelper.GetLabAccessTokenAsync(authority, new[] { resource + "/.default" }).ConfigureAwait(false));
 }