SDK
SDK Golang v1.x
1

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

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")
}