Python API: check if authentication is still valid

Hi everyone :slight_smile:

I wrote a python script using the official python wrapper for the asana API. Authentication and all the others things i planed to do are working very well, but when my token expires after 60 minutes I struggle to detect that. Is there a method to check if authentication is still valid?
Seems not to be updated when the 60 minutes expire.

Thanks a lot and have a nice day!

Hey @Jakob_Developer!

Good question. It looks like our library uses requests-oauthlib, who’s docs are here:

I think the best solution is the third option, automatic refreshing. With our lib in it’s current state, you should be able to do it with something like this:

  token={'access_token': accessToken},

Warning: The above code is psudocode, I haven’t tested that these are the right params in the right place.

This looks like something we will add to the client library in the future, as having you deal with the refresh logic can be a pain.

In the mean time, if you’d rather just get up and running asap. You can use the try except logic of the first or second options in the link.