Beispiel #1
0
        private async Task CreateNewTokenAndHttpClient()
        {
            oAuthTokenInfo = await GetOAuthToken();

            httpClient = new HttpClient();
            httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(oAuthTokenInfo.TokenType, oAuthTokenInfo.AccessToken);
            httpClient.DefaultRequestHeaders.UserAgent.Add(new System.Net.Http.Headers.ProductInfoHeaderValue("IVAedit", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()));
        }
Beispiel #2
0
        private async Task Authorize()
        {
            if (!string.IsNullOrEmpty(clientID) && !string.IsNullOrEmpty(encodedClientSecret) && (oAuthTokenInfo == null || oAuthTokenInfo.ExpirationDate <= DateTime.Now))
            {
                oAuthTokenInfo = await GetOAuthToken(clientID, Encoding.Unicode.GetString(Convert.FromBase64String(this.encodedClientSecret)), username, Encoding.Unicode.GetString(Convert.FromBase64String(this.encodedPassword)));

                httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(oAuthTokenInfo.TokenType, oAuthTokenInfo.AccessToken);
            }
        }