1.2 Get Token

The Get Token endpoint facilitates the processing of a given token, subsequently returning a new token for the user. The provided user token is decoded to ascertain the user's identity.

Method: POST

Endpoint

https://sdk.hypergpt.ai/user/get_token

Parameters (Query String):

  • token (str): The JWT (JSON Web Token) received from the user. This token is used to authenticate the user and perform the required operations.

Return Value:

  • token (str): The newly created or updated user token.

Functionality:

  • decodeJWT(token): Decodes the provided token to determine the user's identity.

  • get_token(token): Performs the necessary operations using the provided token to create or update the token.

  • The endpoint returns the new token in JSON format.

If an exception occurs during the token creation or update process:

  • Logs the error in the API usage history.

  • Raises an HTTP 400 exception with the error message.

Params:

token

api_key

Example Request:

POST /user/get_token?token=api_key

Example Response:

{
    "token": "new_user_token"
}

Example Error Response:

{
    "detail": "Error during token generation"
}

This endpoint allows users to receive a new or updated token based on an existing JWT. It validates the user's token, processes the token update, and returns the new token. If an error occurs during the token creation or update process, an appropriate error message is returned.

Last updated