Golang JWT Gin middleware returns invalid JWT when using RS256

Hi there! :wave:

I am very new to Auth0 but I do have experience with JWT tokens and auth in general.

I am using the Go SDK and I am having trouble getting JWT token verification to work with RS256.

I followed this tutorial first, and the part where they use a locally created HS256 token works great. As soon as they switch to RS256 on auth0, I cant follow the tutorial anymore because I keep getting:

  "message": "JWT is invalid."

The token I am creating on the test page using curl is a bonafide RS256 token, I have checked on the JWT website.

I then have found this official example, which when followed to a tee, still returns the same invalid token error.

The reason I want to follow these tutorials is because I want to use this as a middleware with Gin!

I have to admit I find the fact that I have an app and an api on the Auth0 dashboard a bit confusing as they seem to overlap somewhat in what they do, so perhaps the error is somewhere there.

If there is anything I can help you with to help me, I’ll be here! Thank you!

Hi @tymscar,

Welcome to the Auth0 Community!

An example token and code snippet of your verification setup would be very helpful.

Thank you!

Hi Dan!

Example of the code I used was the one I linked from the official github page.

I managed to solve my error today. The issue was that in the readme it says to copy the tenant url from my auth0 account. That does not have the https prefix when copied from my auth0 account, and the code doesn’t add the prefix.

After I added the prefix myself to it in my env file it worked great.

1 Like

Awesome, thanks for the update.

1 Like