Magento2 API – How to Check if Authorization Token is Valid

apimagento2

I am making an mobile app using magento 2 api (Token-based authentication). and I am confused on its expiration. I know that you can set Customer/Admin Token expiration time in Magento Settings. But how do i get that time with an API call?

I am asking this because in most apps user is logged in a shop until he presses logout so i will store this token in my app.

In docs i don't see integration/customer/token returning expiration time and hard coding that value from settings is a bad idea since its value might change. Am i missing something here?

(I could fetch/generate token every time user opens the app but what is the point in expiration then, because that will just generate more tokens for the user that already might logged in).

Best Answer

After Searching for a way to do this, for now I found out that I can check if token is valid with /rest/V1/customers/me + Authorization Header with token. It is not the best way and the way i wanted, but for now it will have to do.

Related Topic