示例#1
0
        /// <summary>
        /// Gets the access token.
        /// </summary>
        /// <returns>
        /// The access token.
        /// </returns>
        protected APIContext GetApiContext()
        {
            try
            {
                EnsureSslTslChannel();

                var attempt = _settings.GetApiSdkConfig();

                if (!attempt.Success)
                {
                    throw attempt.Exception;
                }

                var accessToken = new OAuthTokenCredential(_settings.ClientId, _settings.ClientSecret, attempt.Result).GetAccessToken();

                return(new APIContext(accessToken));
            }
            catch (Exception ex)
            {
                var logData = GetLoggerData();
                MultiLogHelper.Error <PayPalApiServiceBase>("Failed to create PayPal APIContext", ex, logData);
                throw;
            }
        }