When the API returns 401 and the token looks right, the answer is almost always in the payload: an expired exp, an aud that does not match, a claim with the wrong name. Pasting the token here shows header and payload as JSON instantly, and it is the fastest way to find the cause.
The point that trips up newcomers: decoding is not verifying. Anyone can read a JWT payload, because it is just Base64URL. Integrity comes from the signature, and it is only checked when you provide the secret or public key. The libraries page lists implementations per language, with the algorithms and claim checks each one supports.
The security rule is simple. A production token is a valid credential until it expires, so do not paste it into a third-party site, let alone together with the signing secret. For debugging, mint a development token with a throwaway secret.