Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

7 Comments

  1. Hello
    I’m new to go programming language
    I’m having trouble understanding the following code

    Token Controller – Generating JWTs in Golang
    at line 37:
    claims, ok := token.Claims.(*JWTClaim)

    Why Interface “Claims” can Extract and Map to JWTClaim?

  2. I followed your tutorial and all is well, but…
    When I send the token to test /api/secured/ping it returns: “error”: “tokenstring should not contain ‘bearer ‘”
    How to solve it

    1. Late answer, but if it can help someone in the future:
      I had the same error as you. I had to search deeper and debug to realize that in auth0.go line 8 :
      tokenString := context.GetHeader(“Authorization”)

      Does not return only the token string itself but a string containing “Bearer tokenstring”. So you need to parse this string to retrieve only the token string.
      Here is a stack overflow question who helped me understand what was going on :
      https://stackoverflow.com/questions/44497550/how-to-retrieve-a-bearer-token-from-an-authorization-header-in-javascript-angul

      A quick but not optimal solution is to remove the Bearer word from the string:
      tokenValue := tokenString[7:]