How to check if the user is Authenticated(access token is expried or not) in Android

Hi All,

How to check if the user is Authenticated(access token is expired or not) in Android.

We have OktaAppAuth.isUserLoggedIn(), and it is checking just the null check on the access token, So it returns always true even if the token is expired.

Can you please guide the right method to check the token expiration.

Thanks in Advance,
Jagadesh

Hi Jagadesh,

If you have a access token, performing any authorized request will also handle getting new tokens for you if required.

You can check the expiration time with:
mOktaAppAuth.getAccessTokenExpirationTime();

Please see the samples UserInfoActivity.java

If you need more detailed information about the tokens you can use the introspect endpoint
https://developer.okta.com/docs/api/resources/oidc#introspect

Regards,
Fei