python-o365
python-o365 copied to clipboard
How to check the token validity?
I'm looking for a way to check the token validity. For example, I've stored a long-term token (i.e. refresh token) into the DB using TokenBackend instance, but I revoke that credentials manually via microsoft account consent page or maybe it exceeds from 90 days. Now, I want to check the existing token validation.
It would be great if there was a way to check the validity of the existing tokens something like this:
class TokenBackend(BaseTokenBackend):
...
def check_token_validation(self):
if self.token and self.token.is_validate and not self.token.is_expired:
return True
return False
I found out that there is a .is_expired property for the token, but the problem is despite the fact that I revoke the application credential using microsoft account consent page the following code returns False:
credentials = TokenBackend(user).get_token()
print(credentials.is_expired)
Is expired just checks the token validity based on the type of token, the token issue time and the current time.
I don’t know if there’s an api call to check that.
@janscas
Actually, I also have experience working with google api client, for this case uses calling a method named refresh() which calls the refresh token to check the validity of the token.
Actually, I also have experience working with google api client, for this case uses calling a method named
refresh()which calls the refresh token to check the validity of the token.
This is not implemented for the moment