Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jwt: unexpected token algorithm "Error" #11

Closed
BenCherif opened this issue Mar 2, 2022 · 2 comments
Closed

jwt: unexpected token algorithm "Error" #11

BenCherif opened this issue Mar 2, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@BenCherif
Copy link

BenCherif commented Mar 2, 2022

i've test the token and public on jwt and it works fine but when i try it with this pkg i get "jwt: unexpected token algorithm"

verifiedToken, err := jwt.Verify(jwt.RS512, publicKEY, []byte(token))
check this test jwt

@kataras kataras closed this as completed in da1ee79 Mar 9, 2022
@kataras
Copy link
Owner

kataras commented Mar 9, 2022

Hello @BenCherif , thanks for opening this one. This is fixed now. However, you can always customize how the header is compared using the jwt.VerifyWithHeaderValidator or globally through the jwt.CompareHeader variable. See

// Customize header and public key. This is useful when you want to accept different type of algorithms.
// compareHeader := func(alg string, headerDecoded []byte) (jwt.Alg, jwt.PublicKey, error) {
// return jwt.RS512, publicKey, nil
// }
//
// jwt.CompareHeader = compareHeader
// OR if you don't want to change it globally, use the VerifyWithHeaderValidator when verifying a token:
// verifiedToken, err := jwt.VerifyWithHeaderValidator(jwt.RS256, publicKey, token, compareHeader)
.

@kataras kataras added the bug Something isn't working label Mar 9, 2022
@GsusMorendez
Copy link

GsusMorendez commented Apr 26, 2022

i still get this error

verifiedToken, err := jwt.Verify(jwt.HS256, publicKey, []byte(tokenString))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants