Esempio n. 1
0
        public BaseEndpoint(IOAuth2Wrapper oAuth2Wrapper, int retryMax)
        {
            if (oAuth2Wrapper.isAnonymous)
            {
                _client             = new HttpClient();
                _client.BaseAddress = oAuth2Wrapper.baseUri;
                _retry_max          = retryMax;
                _oAuth2Wrapper      = oAuth2Wrapper;
                return;
            }

            _oAuth2Wrapper = oAuth2Wrapper;
            _retry_max     = retryMax;

            if (_oAuth2Wrapper.isInitialized && _oAuth2Wrapper.tokenExpires > DateTime.UtcNow)
            {
                _token = _oAuth2Wrapper.accessToken;
            }
            else
            {
                _oAuth2Wrapper.isInitialized = _oAuth2Wrapper.GetBearTokenAsync().Result;
            }

            if (_oAuth2Wrapper.isInitialized)
            {
                _client             = new HttpClient();
                _client.BaseAddress = _oAuth2Wrapper.baseUri;
                _client.DefaultRequestHeaders.TryAddWithoutValidation("Authorization",
                                                                      $"Bearer {_oAuth2Wrapper.accessToken}");
            }
        }
Esempio n. 2
0
        /// <summary>
        /// BaseUrl http://upapi.edevnet.intrafinity.com/
        /// </summary>

        public Endpoint(IOAuth2Wrapper oAuth2Wrapper, int retryMax)
            : base(oAuth2Wrapper, retryMax)
        {
        }