# Save and show logged in device information for each access token

**URL:** <https://community.auth0.com/t/save-and-show-logged-in-device-information-for-each-access-token/35793>\
**Category:** Get Help\
**Created:** [January 3, 2020, 2:16pm UTC](https://community.auth0.com/t/save-and-show-logged-in-device-information-for-each-access-token/35793 "2020-01-03T14:16:11Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![georgysavva](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/georgysavva/32/18219_2.png) [@georgysavva](https://community.auth0.com/u/georgysavva)\
**Post date:** [January 3, 2020, 2:16pm UTC](https://community.auth0.com/t/save-and-show-logged-in-device-information-for-each-access-token/35793/1 "2020-01-03T14:16:11Z")

</div>

Hi. I have several first-party applications that interact with my API (e.g IOS app, Android app, Single page web App), and I also expose my API to third party applications. I want to implement the following feature:  
Show all logged in devices (i.e. sessions for firsty-party applications) to the user with information about those devises such as Phone model, OS, Browser/Application name, IP address, last time it was used, etc. (Most often this information is shown on the same page as the “log out from all devices” button)  
When first-party applications call my API, the backend only has the access token provided by the application, but this token lives a short period of time and I can’t associate that device information with the access token. A better alternative is to associate it with the refresh token since it’s permanent, but applications shouldn’t send refresh tokens to the API as I understand. Taking into account answer to my previous [question](http://community.auth0.com/t/log-out-from-all-first-party-applications/35652/2) I think it could be associated with the grand id that I use to delete a grant, but I don’t know how to get the grand id from the access token.  
So how can I bound device info with the tokens provided by the auth0?

---

<div class="post-metadata">

**Author:** ![RatzlaffM](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ratzlaffm/32/15439_2.png) [@RatzlaffM](https://community.auth0.com/u/RatzlaffM)\
**Post date:** [January 4, 2020, 6:16am UTC](https://community.auth0.com/t/save-and-show-logged-in-device-information-for-each-access-token/35793/2 "2020-01-04T06:16:33Z")

</div>

Link is to good. Information is correct.

---

<div class="post-metadata">

**Author:** ![RatzlaffM](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ratzlaffm/32/15439_2.png) [@RatzlaffM](https://community.auth0.com/u/RatzlaffM)\
**Post date:** [January 7, 2020, 6:27am UTC](https://community.auth0.com/t/save-and-show-logged-in-device-information-for-each-access-token/35793/4 "2020-01-07T06:27:22Z")

</div>

I have to change something in your side, if you don’t mind i will tell you[.](https://www.liteblue.buzz)

---

<div class="post-metadata">

**Author:** ![georgysavva](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/georgysavva/32/18219_2.png) [@georgysavva](https://community.auth0.com/u/georgysavva)\
**Post date:** [January 9, 2020, 2:54pm UTC](https://community.auth0.com/t/save-and-show-logged-in-device-information-for-each-access-token/35793/5 "2020-01-09T14:54:24Z")

</div>

Does any one know the solution? I still didn’t figure out have to implement it.

---

<div class="post-metadata">

**Author:** ![nicolas\_sabena](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nicolas_sabena/32/6064_2.png) [@nicolas\_sabena](https://community.auth0.com/u/nicolas_sabena)\
**Post date:** [January 14, 2020, 7:33pm UTC](https://community.auth0.com/t/save-and-show-logged-in-device-information-for-each-access-token/35793/6 "2020-01-14T19:33:30Z")

</div>

Hey @georgysavva apologies in the delay coming back to you.

As I said in the other thread, the mechanism for revoking refresh tokens in Auth0 is by deleting a grant.

A grant is a combination of:

- The application that requested the grant
- The user that granted the permission
- The target API (the audience of the token)
- The scopes (permissions) represented by the grant.

Every time your backend API receives an access token, you get all of the above:

- The user, in the `sub` claim
- The application that requested the grant, in the `azp` claim (authorized party)
- The audience (the identifier of the API) in the `aud` claim.
- The scopes in the `scope` claim

Your API could maintain a table of (`sub, azp, aud, ip address, device`) with “device” being whatever the app sends as a device identifier. This information then could be used to display the list of logged in devices.

Does that help?

---

<div class="post-metadata">

**Author:** ![georgysavva](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/georgysavva/32/18219_2.png) [@georgysavva](https://community.auth0.com/u/georgysavva)\
**Post date:** [January 15, 2020, 10:34am UTC](https://community.auth0.com/t/save-and-show-logged-in-device-information-for-each-access-token/35793/7 "2020-01-15T10:34:43Z")

</div>

Hi. Thanks for the answer. As I understand the combination of those fields (app, user, audience, scopes) doesn’t uniquely identify the access token. Let’s imagine the following situation:  
User logged in on two his mobile phones (Phone 1 and Phone 2) using first-party IOS application and he using the backend API.  
So he has two distinct access tokens per device. But fields that you listed will be the same:

1. It’s the same user.
2. It’s the same first-party IOS application
3. The same backed API
4. The same scope, since it’s a first-party application.

And now he is using the Phone 1 and wants to log out particularly the Phone 2. Or for example he wants to log out all sessions except the current one on the Phone 1.  
In order to do that I need to add something to the table that you described that will uniquely identify the token. Do you understand that I mean?  
Thanks a lot for helping me to figure that out!

---

<div class="post-metadata">

**Author:** ![nicolas\_sabena](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nicolas_sabena/32/6064_2.png) [@nicolas\_sabena](https://community.auth0.com/u/nicolas_sabena)\
**Post date:** [January 20, 2020, 12:08am UTC](https://community.auth0.com/t/save-and-show-logged-in-device-information-for-each-access-token/35793/8 "2020-01-20T00:08:40Z")

</div>

Hi @georgysavva.  
Note that you can invalidate _refresh tokens_, not access tokens. Access tokens will simply expire, and the app trying to use a refresh token to renew the access token will find that it’s no longer valid.

I understand what you mean, and unfortunately there are no built-in feature to help with this use case. You can only go to the “app” (client\_id) level, but no different devices. This could be a great feature request for [Auth0: Secure access for everyone. But not just anyone.](https://auth0.com/feedback)

---

<div class="post-metadata">

**Author:** ![georgysavva](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/georgysavva/32/18219_2.png) [@georgysavva](https://community.auth0.com/u/georgysavva)\
**Post date:** [January 20, 2020, 11:00am UTC](https://community.auth0.com/t/save-and-show-logged-in-device-information-for-each-access-token/35793/9 "2020-01-20T11:00:54Z")

</div>

Thanks for the answer, now I get it. I will submit a feature request.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [January 20, 2020, 12:01pm UTC](https://community.auth0.com/t/save-and-show-logged-in-device-information-for-each-access-token/35793/10 "2020-01-20T12:01:34Z")

</div>

Thanks a lot for that @georgysavva!
