Webhook registration failing with 401 though the token is valid [using atlassian-jwt-py library]

Hi Community,

We have been facing 401 - Unauthorised issue while migration webhook registration though having a valid JWT token using python code. We are getting the installation payload on app installation and using that to construct a JWT token using the below code,
token = atlassian_jwt.encode_token(apiMethod, apiPath, payload['clientKey'], payload['sharedSecret'], 180)
It is throwing 401 issues for other product REST endpoints as well. I have tried with both the python libraries i.e. atlassian-jwt and PyJWT and validated the generated token in https://jwt.io it shows correct but not sure why throwing 401.
Note: I am on Python 2.7 version, atlassian-jwt 1.9.0, PyJWT 1.7.1

Your help will be greatly appreciated. Thanks

Found answer in How do I sign my JWT requests for the REST interface? - #11 by jhazelwood