Tutorials ยท 3 min read

Photo by ThisIsEngineering from Pexels

Listing, retrieving, and deleting delegated tokens

You can list all delegated tokens to see which ones you want to keep or delete, retrieve details about a specific delegated token, or delete a delegated token. In this tutorial you'll learn how to do all of this in Python!

Erikka Innes

February 16, 2021

If you've used delegated tokens to make uploads, you might have a bunch of tokens floating around that you don't know about. With a little bit of code, you can find out how many tokens you have and whether they're going to expire soon. You can also retrieve details about a specific token, or delete one if you have the token identifier. We'll go over how to do all of this in this tutorial!

Take inventory of all your tokens with this code sample.

Code Sample

For starters, here's the complete code sample for everything we'll be doing.

python

List All Delegated Tokens

You can list all delegated tokens you've created by calling the upload-tokens endpoint. Following the complete code sample posted above, after you retrieve your authentication token, you send a request with an optional query string where you can filter how the tokens are returned.

If you set currentPage in your request, the tokens will be returned from the page you choose onwards. If you don't have that many to reach that page, then you won't receive any tokens back. You can also set how many tokens come back per page. Finally, if you don't set any of this information, the default is 25 tokens per page, and information is returned from the first page onwards.

Another way to filter how the data comes back is by token's time-to-live and when it was created.

python

Retrieve Details About One Token

You can retrieve details about a token if you have the unique identifier for the token. This is actually the value of the token itself when you create a new one.

If you save token information, you can add it to a request to retrieve details. Otherwise, you can try list all tokens and then search for the one you want information about.

Retrieving information about a token is straightforward, you include the token in the URL of your request, and authenticate as normal.

python

Delete a Token

You may find that you accumulate more delegated tokens than you expect. Because they don't expire if you don't add a time-to-live, you may want to delete them after awhile. To do that, use retrieve all tokens to find which tokens haven't expired, then send a DELETE request with the token as part of the URL.

python

If you want to find out more about what you can do with delegated tokens, give delegated uploads a try!

You May Also Like...

Try out more than 80 features for free

Access all the features for as long as you need.
No commitment or credit card required

Video API, simplified

Fully customizable API to manage everything video. From encoding to delivery, in minutes.

Built for Speed

The fastest video encoding platform. Serve your users globally with 140+ points of presence.ย 

Let end-users upload videos

Finally, an API that allows your end-users to upload videos and start live streams in a few clicks.

Affordable

Volume discounts and usage-based pricing to ensure you donโ€™t exceed your budget.