CheckToken

Checks the validity of an authentication token.

Arguments

Copied to clipboard!
func (a *Auth) CheckToken(token string) (*TokenValidity, error)
Arguments Type Description Required
token
string
the token yes

Return

A TokenValidity struct which contains:

Name Type Description
Valid
boolean
Tell if the token is valid or not
State
string
Explain why the token is invalid
Expires_at
int
Tells when the token expires

Usage

Copied to clipboard!
jwt, _ := kuzzle.Auth.Login("local", json.RawMessage("{\"username\":\"foo\",\"password\":\"bar\"}"), nil)
res, err := kuzzle.Auth.CheckToken(jwt)
if err != nil {
  log.Fatal(err)
} else {
  if res.Valid != true {
    log.Fatal("Invalid token")
  }
  fmt.Println("Success")
}