nopSolutions/nopCommerce · critical · NopException

Client ID is not set

Error message

Client ID is not set

What it means

Thrown inside GetAccessTokenAsync (a private utility in UPSService) when the UPS ClientId setting is null or empty. This method lazily generates and caches an OAuth access token for UPS API calls. Without a ClientId, the OAuth token request to UPS cannot be constructed, so all subsequent UPS API operations (rate quotes, label generation, tracking) will fail.

Source

Thrown at src/Plugins/Nop.Plugin.Shipping.UPS/Services/UPSService.cs:115

        _workContext = workContext;
        _upsSettings = upsSettings;
    }

    #endregion

    #region Utilities

    /// <summary>
    /// Get access token
    /// </summary>
    /// <returns>The asynchronous task whose result contains access token</returns>
    private async Task<string> GetAccessTokenAsync()
    {
        if (!string.IsNullOrEmpty(_accessToken))
            return _accessToken;

        if (string.IsNullOrEmpty(_upsSettings.ClientId))
            throw new NopException("Client ID is not set");

        if (string.IsNullOrEmpty(_upsSettings.ClientSecret))
            throw new NopException("Client secret is not set");

        var client = new OAuthClient(_httpClientFactory.CreateClient(NopHttpDefaults.DefaultHttpClient), _upsSettings);

        var response = await client.GenerateTokenAsync();
        _accessToken = response.Access_token;

        return _accessToken;
    }

    /// <summary>
    /// Get the weight limit for the selected weight measure
    /// </summary>
    /// <returns>
    /// A task that represents the asynchronous operation
    /// The task result contains the value

View on GitHub (pinned to 64bdf2ff08)

Solutions

  1. Register an app on the UPS Developer Kit portal to obtain a Client ID and Client Secret
  2. Enter the Client ID at Admin > Configuration > Shipping > UPS > Configure
  3. Verify the setting persisted by checking Admin > Configuration > Shipping > UPS settings
  4. Ensure the correct store scope is selected when entering credentials in multi-store setups

Example fix

// before
var rates = await _upsService.GetRatesAsync(request);

// after — validate credentials before any UPS API call
if (string.IsNullOrEmpty(_upsSettings.ClientId))
    throw new InvalidOperationException("UPS Client ID is not configured");
var rates = await _upsService.GetRatesAsync(request);
Defensive patterns

Strategy: validation

Validate before calling

// Validate UPS Client ID before any shipping operation
if (string.IsNullOrEmpty(_upsSettings.ClientId))
    throw new InvalidOperationException("UPS Client ID is not configured. Set it in Admin > Shipping > UPS.");

Try / catch

// UPS errors throw directly (not wrapped); caller must catch
try
{
    var rates = await _upsService.GetRatesAsync(request);
}
catch (NopException ex) when (ex.Message.Contains("Client ID"))
{
    _logger.Error("UPS credentials missing — shipping rates unavailable");
    return ErrorResult("Shipping calculation temporarily unavailable");
}

Prevention

When it happens

Trigger: _upsSettings.ClientId is null or empty string when GetAccessTokenAsync is called and no cached _accessToken exists yet. This happens on the first UPS API call after application startup with unconfigured credentials.

Common situations: UPS plugin installed but credentials not entered; ClientId was registered on the UPS developer portal but not copied into plugin settings; settings were reset; environment-specific config (dev vs prod) not switched; credential field left blank during initial setup.

Related errors


AI-assisted analysis of nopSolutions/nopCommerce@64bdf2ff08 (2026-08-13). Data as JSON: /api/errors/39e38a5e4ed26517. Report an issue: GitHub.