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.
MethodGET
Endpoint/v2/consumer/verify/
Query Parameters
None
Auth Required
Yes
Example Request #
cURL
curl -X GET \
https://tbe.thuprai.com/v2/consumer/verify/ \
-H 'Authorization: Bearer <your-auth-token>'
2
3
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)
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
{
"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
}
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
to2023-10-08
. - the token enables the consumer to hit the
event
andevent/ticket
endpoints, which should allow accessing event details, and creating event tickets. - resources of type
event
with ids513
and514
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
{ "detail": "You used an invalid token." }
Or #
Condition : If the auth token exists but is disabled.
Code : 403 Forbidden
Content
{ "detail": "Token has been disabled." }
Or #
Condition : If the auth token is not valid for the current date.
Code : 403 Forbidden
Content
{ "detail": "Token not valid for today." }