Token Info - Seluj78/IntraPy GitHub Wiki

As seen on the API documentation, you can get more info on the token given by the api, and that we handle for you

Don't worry ! We have that covered for you too !

get_uid_from_token

If, for any reason, you need to know what uid you are using and want to get it through the API instead of using the one stored in your settings.ini, you can use this function.

This function has a really simple use:

from IntraPy.IntraPy import IntraPy

api = IntraPy()
print(api.get_uid_from_token())

will get you your uid:

8ngp6jutwr7ge667eqsnqqacppk7wkv2v6hk7rdtvbtzfu82krdeakg3x4rvcra3

get_token_expire_time_in_seconds

If you need to know in how many seconds your token will expire, this function is for you. It will return string that you can simply use in your own script/bot/app to know when will the token expire.

For example, if you just want to print how many seconds are left, do:

from IntraPy.IntraPy import IntraPy

api = IntraPy()
print(api.get_token_expire_time_in_seconds())

And it will print in the console how many seconds you have left.

By default, a token has an expiry time of 2 hours or 7200 seconds

get_token_expire_time

If you need to get the expiry time of your token in the hours:minutes:seconds, to display it or for ease of understanding when debugging, you can use this function.

To use it, simply call it and use the result. In this example, we print it:

from IntraPy.IntraPy import IntraPy

api = IntraPy()
print(api.get_token_expire_time())
1:59:22
By default, a token has an expiry time of 2 hours or 7200 seconds

get_token_creation_epoch

If you need to know when the token you are using was created and you want it in the epoch format, this function is for you.

Really simple to use, just call it to get the epoch creation date:

from IntraPy.IntraPy import IntraPy

api = IntraPy()
print(api.get_token_creation_epoch())
1516189402
Please note that this is an illustration epoch date, and relates to when this wiki was written

get_token_creation_date

If you need the exact date and time of creation of your token and you don't want it in the epoch format, then this function is for you. It will return a string containing the date and time of creation of your token in this form: YYYY-MM-DD hh-mm-ss

To use it, simply call it. In this example, we'll print it:

from IntraPy.IntraPy import IntraPy

api = IntraPy()
print(api.get_token_creation_date())
2018-01-17 12:43:22
Please note that this is an illustration date, and relates to when this wiki was written