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
Fei
March 8, 2019, 12:54am
2
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
/*
* Copyright (c) 2017, Okta, Inc. and/or its affiliates. All rights reserved.
* The Okta software accompanied by this notice is provided pursuant to the Apache License,
* Version 2.0 (the "License.")
*
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
* See the License for the specific language governing permissions and limitations under the
* License.
*/
package com.okta.appauth.android.example;
import android.app.PendingIntent;
import android.content.Intent;
import android.net.Uri;
This file has been truncated. show original
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
system
Closed
January 17, 2024, 7:48pm
3
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.