JWT generation as a Github app #49521
-
Hi there! I'm trying to create a JWT token from a private key generated in a .pem file for a Github app using the JWTS library in java. Sample token : eyJhbGciOiJSUzI1NiJ9.eyJpYXQiOjE2NzgyODg4OTcsImV4cCI6MTY3ODI4OTQ5NywiaXNzIjoiMjkzNjY3In0.a0xnRHblUPX0HbN2a__JFLdAkLT5IE7sfGoZK2BuWi0s-Q-k0KGwK5RUYKnWZuArmQ946bTfjiMz0TM8v_iv78Q7rxM45Cb7rC-iiJ4P7Io25mJ2QuoQ0ASDKJ5wtXh8LZQwCElP7nT2NmtB-Fe2pUfv5uR8W_yk-TqDrVTZTmIIjnrq0lpcS7YSkcPDj__yC3a5BRNcctnX_ot7rCfJcFd5WNy8h5tp_dt6dyzFIk4AwCfeSlClKBU0JE-SiH6UwWWE31Uy6EiAS6HBWlIPk5o3KvJ7cAcWub1kUJmmr8oDKhMjtUcAko1glS9fljYQ8IbuC-08GlSOBcd_C_caXA
Can someone help me with this? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Hi Sayed, I was able to fix the problem. It was not with the way I was reading the file and JWT token generation was fine. I had to do an extra step of passing the generated token to the GitHub installations API for fetching the access token. Which will be used to authenticate with GitHub as an app. You can follow the below link to see the steps. |
Beta Was this translation helpful? Give feedback.
-
I'm still facing same issue, jwt created is of invalid signature , has anyone able to resolve it yet ? I tried using bouncyCastle lib for pkcs#1 format and other way converting .pem to pkcs#8 format but in both the ways the jwt token created is having a Invalid signature . Any help will be appreciated. |
Beta Was this translation helpful? Give feedback.
Hi Sayed,
Thanks for the reply.
I was able to fix the problem.
It was not with the way I was reading the file and JWT token generation was fine. I had to do an extra step of passing the generated token to the GitHub installations API for fetching the access token. Which will be used to authenticate with GitHub as an app.
You can follow the below link to see the steps.
https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/generating-an-installation-access-token-for-a-github-app#generating-an-installation-access-token