nopSolutions/nopCommerce · critical · NopException

Client secret is not set

Error message

Client secret is not set

What it means

Thrown inside GetAccessTokenAsync when the UPS ClientSecret setting is null or empty. The OAuth token exchange with UPS requires both ClientId and ClientSecret. This is the second credential check after ClientId — if ClientId passes but ClientSecret is empty, the token request would fail at the UPS OAuth endpoint.

Source

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

    #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
    /// </returns>
    private async Task<decimal> GetWeightLimitAsync()
    {

View on GitHub (pinned to 64bdf2ff08)

Solutions

  1. Obtain the Client Secret from the UPS Developer Kit portal alongside the Client ID
  2. Enter the Client Secret at Admin > Configuration > Shipping > UPS > Configure
  3. Verify both Client ID and Client Secret are saved together
  4. If credentials were regenerated on the UPS portal, update both fields in the plugin settings

Example fix

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

// after — validate both OAuth credentials before calling
if (string.IsNullOrEmpty(_upsSettings.ClientId) || string.IsNullOrEmpty(_upsSettings.ClientSecret))
    throw new InvalidOperationException("UPS OAuth credentials are not configured");
var rates = await _upsService.GetRatesAsync(request);
Defensive patterns

Strategy: validation

Validate before calling

// Validate UPS Client Secret before any shipping operation
if (string.IsNullOrEmpty(_upsSettings.ClientSecret))
    throw new InvalidOperationException("UPS Client Secret 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 secret"))
{
    _logger.Error("UPS Client Secret missing — shipping rates unavailable");
    return ErrorResult("Shipping calculation temporarily unavailable");
}

Prevention

When it happens

Trigger: _upsSettings.ClientSecret is null or empty when GetAccessTokenAsync is called (after the ClientId check already passed) and no cached token exists.

Common situations: Only the Client ID was entered but the Client Secret was left blank during configuration; the secret was regenerated on the UPS portal making the stored one invalid (though this would typically produce a different error); copy-paste error where the secret field was skipped.

Related errors


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