Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

If a JWT succeeds locally but returns 401 Unauthorized in production, first establish whether the production API received the intended access token. Then compare what the production validator trusts and expects: the signing algorithm and key, issuer, audience, and token time claims. A 401 generally points to authentication or token acceptance; a 403 usually means authentication succeeded but authorization denied the request.

Start by separating a 401 from a 403

A 401 means the request was not accepted as authenticated. In ASP.NET Core, documented causes include an invalid signature, an expired token, or a missing or invalid issuer or audience. A 403 instead points toward authorization: the caller may be authenticated but lack a required role, scope, policy, or permission. These meanings are useful diagnostic clues, not proof of the exact failure in every framework or API.

For ASP.NET Core 9.0, Microsoft says a server returning 401 must include a WWW-Authenticate challenge. Inspect the response headers and server-side authentication diagnostics where available; do not assume that changing authorization policies will fix a token the API has rejected.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check these five things first

1. Confirm production receives the intended bearer token

Inspect the request at the API boundary for the failing call. Confirm that the intended access token is present in the Authorization header using the bearer scheme, rather than missing, truncated, or replaced by a different token. Compare the complete request path with the successful local call, including any gateway or proxy between the client and API.

#1 Best Overall
Yubico - Security Key C NFC - Basic Compatibility - Multi-Factor authentication (MFA) Security Key and passkey, Connect via USB-C or NFC, FIDO Certified
  • POWERFUL SECURITY KEY: The Security Key C NFC is the essential physical passkey for protecting your digital life from phishing attacks. It ensures only you can access your accounts.
  • WORKS WITH 1000+ ACCOUNTS: Compatible with Google, Microsoft, and Apple. A single Security Key C NFC secures 100 of your favorite accounts, including email, password managers, and more.
  • FAST & CONVENIENT LOGIN: Plug in your Security Key C NFC via USB-C and tap it, or tap it against your phone (NFC) to authenticate. No batteries, no internet connection, and no extra fees required.
  • TRUSTED PASSKEY TECHNOLOGY: Uses the latest passkey standards (FIDO2/WebAuthn & FIDO U2F) but does not support One-Time Passwords. For complex needs, check out the YubiKey 5 Series.
  • BUILT TO LAST: Made from tough, waterproof, and crush-resistant materials. Manufactured in Sweden and programmed in the USA with the highest security standards.

If the header is absent at the API, trace where it disappears: client configuration, routing, gateway handling, or another intermediary. A proxy is one possible point of difference, not a universal explanation for production 401s. Avoid logging a live token in full. Use a controlled diagnostic approach that protects credentials, such as checking header presence and examining decoded claims without treating those claims as trusted until validation succeeds.

2. Verify the algorithm and trusted signing key

Compare the token header’s algorithm with the algorithms the production API explicitly allows. Then confirm that the token’s signature validates against a key trusted for the token’s issuer. Do not trust a token merely because its claims can be decoded: claims become suitable for security decisions only after the token is cryptographically verified and bound to the required context.

Rank #2
Thetis FIDO2 Security Key (USB-A, 2-Pack) - Hardware MFA & Passkey Access for Business, School ERP & Employee Accounts | Compatible with Windows, Google Workspace, Apple ID, Coinbase, Salesforce
  • FIDO2 & Passkey Ready: Business-ready and FIDO2 L1 certified. This key is supported by major management suites and is ideal for both individual and enterprise deployment. Works seamlessly with Gmail, Facebook, GitHub, Dropbox, Coinbase, and more.
  • Universal Connectivity (USB-A ): Features a built-in USB-A connector—simply unfold the key and plug it into your compatible PC or laptop for seamless authentication on the go.
  • Dedicated Manager App: Use the Thetis Manager App for the initial hardware PIN setup. Setting the PIN on the device first ensures a smooth registration process. Once the PIN is configured, you can begin registering the key across your favorite FIDO2-compatible online services.
  • Ultra-Durable & Portable: Featuring a rotating metal cover, this key is water, crush, and tamper-resistant. It fits easily on a keychain and requires no batteries or network connectivity.
  • Check FIDO2 compatibility before purchase - Known limitations: ID Austria is not supported (requires FIDO2 Level 2). Windows Hello login only works with Windows Enterprise editions that support Entra ID, and NFC is NOT supported.

For OpenID Connect, issuer metadata can identify the JSON Web Key Set (JWKS) endpoint that publishes signing keys. Check that production can reach the relevant metadata and JWKS, and account for key rotation: a production validator with stale or unavailable keys may reject a token that another environment accepts. RFC 8725 advises verifying algorithms and binding keys to issuers.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

3. Compare the issuer (iss) exactly

Compare the token’s iss value with the issuer configured as valid by the production API. The issuer and signing key must agree: a valid signature from a key that is not trusted for the stated issuer is not enough. Local and production configurations may point to different authorities, so inspect the actual validated settings and token values rather than inferring them from environment names.

Rank #3
Sale
Thetis Nano-A FIDO2 Security Key Hardware Passkey Device with USB Type A, TOTP/HOTP, FIDO2.0 Two Factor Authentication 2FA MFA, Works with Windows/mac/iOS/Android/Linux/Gmail/Facebook/GitHub/Coinbase
  • Ultra-Compact FIDO2 Security Key - Plug-and-stay or carry on a keychain. This USB-A hardware security key offers portable, always-on protection for desktop and mobile use. (Item Size: 0.75 X 0.74 IN x 0.25 IN)
  • USB-A Hardware Key for All Devices - Works with USB-A ports on PC, Mac, Android, and other laptop/notebook device. Enables secure, cross-platform login with FIDO2.0 passkey support.
  • FIDO Certified Security Key - Meets FIDO and FIDO2 standards. Works with Google, Microsoft, GitHub, Dropbox, and more. Please check service compatibility before purchase.
  • Passwordless Login with Passkey - Supports passkey login via WebAuthn and CTAP2. Enjoy password-free sign-ins where supported. Not all websites or services currently support passkeys.
  • Advanced Multi-Factor Authentication - Offers 200 FIDO2 passkey slots and 50 OATH-TOTP slots. Strong, flexible 2FA/MFA support across various apps and authentication platforms.

4. Compare the audience (aud) exactly

The audience identifies the intended recipient of a token. Compare the token’s aud value with the production API’s expected audience, paying attention to exact spelling and case: RFC 7519 defines audience values as case-sensitive strings. A recipient should reject a token whose audience does not identify it. Applications serving multiple relying parties should validate the audience as well, as RFC 8725 recommends.

5. Check expiration, not-before time, and the production clock

Compare exp (expiration) and nbf (not before) with the validator’s current UTC time. A token must not be accepted at or after its expiration, or before its not-before time. Check that the production host clock is synchronized and that the token was issued with a lifetime appropriate for the request.

Rank #4
HORUSDY Tamper Proof Star Key Set (Folding) Security Torx Key Set Sizes Include T-6 to T-30
  • Tamper Resistant Star Key Set Crafted with premium chrome vanadium steel, and each star tool folds neatly into the handle for quick, easy access.
  • Details - The handle is engraved with size for quick identification with drilled tips to allow use.
  • Portable - Keys fold compact for easy storage, Drilled tips allow use on tamper resistant security screws.
  • Size:Full Size T-6, T-7, T-8, T-9, T-10, T-15 T-20, T-25, T-27 and T-30.
  • And with 10 total star sizes able to match nearly all standard tamper resistant security screws on the market.

RFC 7519 permits a small leeway for clock skew, usually no more than a few minutes. That allowance is not a substitute for correcting an inaccurate server clock or an incorrect token lifetime; widening the validation window can extend the time a token is accepted.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Compare the working and failing paths systematically

Once you have the five values, compare the successful local request and the failing production request rather than changing several settings at once. Record the request’s token presence, the token’s relevant validation inputs, and the validator’s effective configuration in each environment. Keep secrets and full tokens out of logs.

Best Value
Thetis Pro For Business - FIDO2 Security Key L1 MFA & NFC Passkey Access For School ERP, Employee Online Account, Compatible with Coinbase Google Workspace Apple ID Window Salesforce,Dual USB A +USB C
  • FIDO2 & Passkey Ready: Business-ready and FIDO2 L1 certified. This key is supported by major management suites and is ideal for both individual and enterprise deployment. Works seamlessly with Gmail, Facebook, GitHub, Dropbox, Coinbase, and more.
  • Dedicated Manager App: Use the Thetis Manager App for the initial hardware PIN setup. Setting the PIN on the device first ensures a smooth registration process. Once the PIN is configured, you can begin registering the key across your favorite FIDO2-compatible online services.
  • Universal Connectivity (USB-C, USB-A, & NFC): Designed for PCs, Macs, iPhones, and Android. For mobile use, simply unfold the key, align it with your phone’s NFC antenna, and hold for a few seconds to authenticate.
  • Enhanced MFA (FIDO2 & TOTP/HOTP): Strengthen your security with flexible options. Use the Manager App to access TOTP/HOTP features for accounts that do not yet support FIDO2.
  • Check FIDO2 compatibility before purchase - Known limitations: ID Austria is not supported (requires FIDO2 Level 2). Windows Hello login only works with Windows Enterprise editions that support Entra ID. NFC is supported only through mobile authentication, Not MacOS/windows.
What to compare Question to answer What a difference can indicate
Bearer delivery Does the API receive the intended token on the failing request? The client or request path differs, or an intermediary changes what reaches the API.
Algorithm and signing key Does production allow the token’s algorithm and trust a key for its issuer? Validation policy, key access, or key rotation differs.
Issuer Does the token’s iss exactly match the production validator’s trusted issuer? The environments use different authorities or issuer configuration.
Audience Does the token identify this API as an intended recipient? The token was issued for another service or the expected audience differs.
Time claims and clock Are exp and nbf valid against production UTC time? The token is outside its validity period or the host clock is wrong.

Use framework guidance as an implementation example

Microsoft’s ASP.NET Core guidance maps invalid signatures, expiration, and missing or invalid issuer or audience to 401 responses, and distinguishes authorization failures as 403 responses. Apply that framework-specific guidance if you use ASP.NET Core; other stacks may expose different diagnostics and configuration names. The underlying checks—delivery, cryptographic trust, issuer, audience, and time validity—remain the core comparisons described by the JWT standards.

Sources

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.