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

auth0.NewValidator not enough args #11

Open
neophiliac opened this issue Mar 23, 2018 · 4 comments
Open

auth0.NewValidator not enough args #11

neophiliac opened this issue Mar 23, 2018 · 4 comments

Comments

@neophiliac
Copy link

Following the instructions in the README, I get

$ go run main.go

command-line-arguments

./main.go:50:34: not enough arguments in call to auth0.NewValidator
have (auth0.Configuration)
want (auth0.Configuration, auth0.RequestTokenExtractor)

Passing nil for the missing parameter seems to work.

@MikaelBrenner
Copy link

Passing nil as parameter results in an error:

square/go-jose: compact JWS format must have three parts
Token is not valid: <nil>

@ryan-popa
Copy link

auth0 provides some helpers for it

"github.com/auth0-community/go-auth0"
"gopkg.in/square/go-jose.v2/jwt"

type jwtHeaderExtractor struct {}

func (e *jwtHeaderExtractor) Extract(r *http.Request) (*jwt.JSONWebToken, error) {
	return auth0.FromHeader(r)
}

client := auth0.NewJWKClient(auth0.JWKClientOptions{URI: JWKS_URI}, &jwtHeaderExtractor{})

@anuzis
Copy link

anuzis commented Jul 15, 2018

Getting the same 'Token is not valid: ' even with the suggested jwtHeaderExtractor. New to auth0 and unfamiliar with the NewJWKClient call as opposed to validator.ValidateRequest. If there's a straightforward fix for this can someone post a pull request?

@charly3pins
Copy link

Using the JWKClient should fix the problem:

auth0Domain := your_auth0_domain
jwkClient := auth0.NewJWKClient(auth0.JWKClientOptions{URI: fmt.Sprintf("%s.well-known/jwks.json", auth0Domain)}, nil)
validator := auth0.NewValidator(auth0.NewConfiguration(jwkClient, []string{}, auth0Domain, jose.RS256), nil)
jwt, err := validator.ValidateRequest(yourRequest)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants