Skip to content
On this page

Verifying Tokens

INFO

The endpoint for verifying tokens exists only so that the consumers can verify if their token exists and find other details about their token. Consumers can directly perform other actions like getting ebook access or generating tickets by hitting the respective endpoints using their token in Authorization header, without having to hit this endpoint at all.

This endpoint allows you to verify if the token you have can authenticate the requests. The endpoint also returns the dates the token is valid for, the endpoints the consumer can make requests to, and identifiers of resource objects the consumer is allowed to make requests.

Method
GET

Endpoint
/v2/consumer/verify/

Query Parameters
None

Auth Required
Yes

Example Request

cURL

bash
curl -X GET \
  https://tbe.thuprai.com/v2/consumer/verify/ \
  -H 'Authorization: Bearer <your-auth-token>'
1
2
3

Python

python
import requests
url = 'https://tbe.thuprai.com/v2/consumer/verify/'
headers = {'Authorization': 'Bearer <your-auth-token>'}
response = requests.get(url, headers=headers)
print(response.text)
1
2
3
4
5

Success Response

Condition : If the authorization token exists, is enabled and is valid for current date.

Code : 200 OK

Content example

json
{
  "consumer": "consumer-name",
  "start_date": "2022-10-09",
  "end_date": "2023-10-08",
  "enabled_resources": ["event", "event/ticket"],
  "resource_ids": {
    "event": [513, 514]
  },
  "enabled": true
}
1
2
3
4
5
6
7
8
9
10

The response suggests that:

  • the token is owned by consumer-name.
  • the token is valid from 2022-10-09 to 2023-10-08.
  • the token enables the consumer to hit the event and event/ticket endpoints, which should allow accessing event details, and creating event tickets.
  • resources of type event with ids 513 and 514 are only accessible for actions for the consumer.
  • the consumer token is currently active.

Error Responses

Condition : If the auth token does not exist.

Code : 403 Forbidden

Content

json
{ "detail": "You used an invalid token." }
1

Or

Condition : If the auth token exists but is disabled.

Code : 403 Forbidden

Content

json
{ "detail": "Token has been disabled." }
1

Or

Condition : If the auth token is not valid for the current date.

Code : 403 Forbidden

Content

json
{ "detail": "Token not valid for today." }
1