title: How to parse a JWT token with RSA in jwt-go ParseWithClaims?
body: <p>I have developed the following method, which should enable token-based authentication (jwt). An asynchronous process should be used to generate the token.</p>
  <p>The source code seems to work up to and including the generation of the signed token.
  I encountered an issue when querying the token with <code>ParseWithClaims</code>. Can someone help please?</p>
  <pre><code>package controllers
  
  import (
      &quot;crypto/rand&quot;
      rsaKeys &quot;crypto/rsa&quot;
      &quot;fmt&quot;
  
      jwtgo &quot;github.com/dgrijalva/jwt-go&quot;
      &quot;github.com/gofiber/fiber&quot;
  )
  
  func Login(c *fiber.Ctx) error {
      
      type TestClaims struct {
          HAPP string `json:&quot;happ&quot;`
          jwtgo.StandardClaims
      }
  
      currentPrivateKey, err := rsaKeys.GenerateKey(rand.Reader, 512)
  
      claims := TestClaims{
          &quot;owa&quot;,
          jwtgo.StandardClaims{
              Issuer:    &quot;test&quot;,
              ExpiresAt: 15000,
          },
      }
  
      token := jwtgo.NewWithClaims(jwtgo.SigningMethodRS256, claims)
  
      tokenSigned, err := token.SignedString(currentPrivateKey)
      if err != nil {
          fmt.Printf(&quot;Failed to sign in account %v&quot;, err)
      }
  
      //Issue is in this statement
      _, errTest := jwtgo.ParseWithClaims(tokenSigned, &amp;TestClaims{&quot;owa&quot;, jwtgo.StandardClaims{}}, func(token *jwtgo.Token) (interface{}, error) {
          return currentPrivateKey, nil
      })
  
      if errTest != nil {
          fmt.Printf(&quot;Error Message: %v&quot;, errTest) //Does throw error: key is of invalid type
      }
  
      return c.JSON(fiber.Map{
          &quot;message&quot;: &quot;success&quot;,
      })
  }
  
  </code></pre>