Python API: check if authentication is still valid

Hey @Jakob_Developer!

Good question. It looks like our library uses requests-oauthlib, who’s docs are here: OAuth 2 Workflow — Requests-OAuthlib 1.3.1 documentation

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:

asana.Client(session.AsanaOAuth2Session(
  client_secret="super_secret", 
  token={'access_token': accessToken},
  auto_refresh_url=refresh_url,
  token_updater=token_saver
))

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.