Error 500 When Requesting Access Token

Hello,

I’m reaching out to report an issue I’ve encountered while attempting to request an access token. I consistently receive a 500 error, accompanied by the following message:

{'message': "Cannot destructure property 'iss' of '(intermediate value)(intermediate value)(intermediate value)' as it is undefined."}

Here’s a brief overview of the steps I took that led to this error:

Environment Setup : I’m using Python and the library from authlib.jose import jwt .
Request Details :

  • JWT Token Function:
def get_jwt_token():
    private_key = base64.b64decode(SAMSUNG_ENCODED_KEY).decode()
    issued = int(round(time.time()))
    exp = int(issued + (20.0 * 60.0))

    header = {
        "alg": "RS256",
        "typ": "JWT",
    }

    payload = {
        "iss": SAMSUNG_ISSUER_ID,
        "iat": issued,
        "exp": exp,
        "scopes": "gss",
    }
    return jwt.encode(header, payload, private_key)

Access Token Function :

def get_access_token(jwt_token):
    headers = {
        "content-type": "application/json",
        "Authorization": f"Bearer {jwt_token}",
    }

    url = "https://devapi.samsungapps.com/auth/accessToken"

    return requests.post(url, headers=headers)

Validation of Constants : I have verified that the variables SAMSUNG_ENCODED_KEY and SAMSUNG_ISSUER_ID contain correct and valid data.

I have tried to troubleshoot this on my own, but the error message does not provide enough information to pinpoint the exact problem. I’ve checked the documentation and ensured that my request is formulated correctly, yet the issue persists.

I would appreciate any insights or guidance from the community or Samsung support team to resolve this issue. If you need any additional information or details, please let me know.

Thank you in advance for your assistance.

Open a Developer Support Request on this. I think it happens often occasionally and each may have a different cause.

Ron
Samsung Developer Relations

1 Like