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

**URL:** <https://devforum.okta.com/t/how-to-check-if-the-user-is-authenticated-access-token-is-expried-or-not-in-android/4417>\
**Category:** Questions\
**Tags:** java\
**Created:** [March 7, 2019, 11:40am UTC](https://devforum.okta.com/t/how-to-check-if-the-user-is-authenticated-access-token-is-expried-or-not-in-android/4417 "2019-03-07T11:40:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jagadeshseeram](https://avatars.discourse-cdn.com/v4/letter/j/5f9b8f/32.png) [@jagadeshseeram](https://devforum.okta.com/u/jagadeshseeram)\
**Post date:** [March 7, 2019, 11:40am UTC](https://devforum.okta.com/t/how-to-check-if-the-user-is-authenticated-access-token-is-expried-or-not-in-android/4417/1 "2019-03-07T11:40:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Fei](https://avatars.discourse-cdn.com/v4/letter/f/59ef9b/32.png) [@Fei](https://devforum.okta.com/u/Fei)\
**Post date:** [March 8, 2019, 12:54am UTC](https://devforum.okta.com/t/how-to-check-if-the-user-is-authenticated-access-token-is-expried-or-not-in-android/4417/2 "2019-03-08T00:54:49Z")

</div>

Hi Jagadesh,

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

> **[okta/okta-sdk-appauth-android](https://github.com/okta/okta-sdk-appauth-android#performing-authorized-requests)**
>
> okta-sdk-appauth-android. Contribute to okta/okta-sdk-appauth-android development by creating an account on GitHub.

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

Please see the samples UserInfoActivity.java

> <https://github.com/okta/okta-sdk-appauth-android/blob/master/app/src/main/java/com/okta/appauth/android/example/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](https://developer.okta.com/docs/api/resources/oidc#introspect)

Regards,  
Fei

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/oktadev/original/1X/589c4c5f80de422d01f47cee7185a7fb8227835c.png) [@system](https://devforum.okta.com/u/system)\
**Post date:** [January 17, 2024, 7:48pm UTC](https://devforum.okta.com/t/how-to-check-if-the-user-is-authenticated-access-token-is-expried-or-not-in-android/4417/3 "2024-01-17T19:48:31Z")

</div>

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
