CheckToken #
Checks the validity of an authentication token.
Arguments #
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 #
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")
}
Edit this page on Github(opens new window)