Skip to content
Start here

Verify Token

client.User.Tokens.Verify(ctx) (*TokenVerifyResponse, error)
GET/user/tokens/verify

Test whether a token works.

Security

API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
ReturnsExpand Collapse
type TokenVerifyResponse struct{…}
ID string

Token identifier tag.

maxLength32
Status TokenVerifyResponseStatus

Status of the token.

One of the following:
const TokenVerifyResponseStatusActive TokenVerifyResponseStatus = "active"
const TokenVerifyResponseStatusDisabled TokenVerifyResponseStatus = "disabled"
const TokenVerifyResponseStatusExpired TokenVerifyResponseStatus = "expired"
ExpiresOn Timeoptional

The expiration time on or after which the JWT MUST NOT be accepted for processing.

formatdate-time
NotBefore Timeoptional

The time before which the token MUST NOT be accepted for processing.

formatdate-time

Verify Token

package main

import (
  "context"
  "fmt"

  "github.com/cloudflare/cloudflare-go"
  "github.com/cloudflare/cloudflare-go/option"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  response, err := client.User.Tokens.Verify(context.TODO())
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.ID)
}
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "success": true,
  "result": {
    "id": "ed17574386854bf78a67040be0a770b0",
    "status": "active",
    "expires_on": "2020-01-01T00:00:00Z",
    "not_before": "2018-07-01T05:20:00Z"
  }
}
Returns Examples
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "success": true,
  "result": {
    "id": "ed17574386854bf78a67040be0a770b0",
    "status": "active",
    "expires_on": "2020-01-01T00:00:00Z",
    "not_before": "2018-07-01T05:20:00Z"
  }
}