JWT token is getting rejected with error "Provide a properly configured and signed bearer token, and make sure that it has not expired."

I am trying to make an api call using a JWT token generated using App store connect api key.

The token is rejected with the following error:

 "errors": [
        {
            "status": "401",
            "code": "NOT_AUTHORIZED",
            "title": "Authentication credentials are missing or invalid.",
            "detail": "Provide a properly configured and signed bearer token, and make sure that it has not expired. Learn more about Generating Tokens for API Requests https://developer.apple.com/go/?id=api-generating-tokens"
        }
    ]

My header and payload are as follow:

Header

{

"alg": "ES256",

"kid": "<MY_KEY_ID>",

"typ": "JWT"

}

Payload

{

"iss": "<MY_ISSUER_ID>",

"aud": "appstoreconnect-v1",

"iat": 1698333493,

"exp": 1698333793

}

I am unable to find what is wrong with my token. Can someone help me with this?

I've had tests in regression that were previously working with a signed jwt token for the past 8 months. about 1.5 weeks ago my sandbox connection tests have been failing and I haven't touched the code to generate the token. Something's up on Apple's end I believe.

JWT token is getting rejected with error "Provide a properly configured and signed bearer token, and make sure that it has not expired."
 
 
Q