<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How to audit if application authentication tokens have been used for login?]]></title><description><![CDATA[<p dir="auto">We have authentication tokens enabled for some applications in FusionAuth, and we want to determine if these tokens have actually been used for authentication in the last 30/90/365 days before disabling the feature.</p>
<p dir="auto">We have approximately 225 users with authentication tokens assigned to their registrations. We can identify which users have tokens using an Elasticsearch query:</p>
<pre><code class="language-json">{
  "bool": {
    "must": [
      {
        "nested": {
          "path": "registrations",
          "query": {
            "exists": {
              "field": "registrations.authenticationToken"
            }
          }
        }
      }
    ]
  }
}
</code></pre>
<p dir="auto">However, we need to confirm whether these tokens have been actively used for authentication. Is there a way to audit authentication token usage through login records or other mechanisms in FusionAuth?</p>
]]></description><link>https://fusionauth.io/community/forum/topic/3327/how-to-audit-if-application-authentication-tokens-have-been-used-for-login</link><generator>RSS for Node</generator><lastBuildDate>Sat, 07 Nov 2026 16:17:11 GMT</lastBuildDate><atom:link href="https://fusionauth.io/community/forum/topic/3327.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 03 Nov 2026 22:46:20 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to audit if application authentication tokens have been used for login? on Tue, 03 Nov 2026 22:46:31 GMT]]></title><description><![CDATA[<p dir="auto">Login records in FusionAuth (via the Login Report) don't distinguish between authentication methods. The response fields include <code>applicationId</code>, <code>applicationName</code>, <code>loginId</code>, <code>loginIdType</code>, <code>instant</code>, <code>ipAddress</code>, and <code>userId</code>, but none indicate the credential type used (token vs. password vs. SSO).</p>
<h2>Recommended Approach</h2>
<p dir="auto">You can determine token usage by checking the <code>lastLoginInstant</code> field on user registrations:</p>
<ol>
<li>Use the <strong>Retrieve User Registration</strong> endpoint (<code>GET /api/user/registration/{userId}/{applicationId}</code>) or search for users with tokens</li>
<li>For each registration with an <code>authenticationToken</code>, check the <code>lastLoginInstant</code> against your time windows (30 days, 90 days, 1 year)</li>
<li>If <code>lastLoginInstant</code> falls within your time window for any user, someone authenticated to that application during that period</li>
</ol>
<p dir="auto">Here's a Python script approach:</p>
<pre><code class="language-python">import requests
from datetime import datetime, timedelta

# Define time windows
windows = {
    '30d': datetime.now() - timedelta(days=30),
    '90d': datetime.now() - timedelta(days=90),
    '1y': datetime.now() - timedelta(days=365)
}

# Pull registrations for your application
# Check each registration's lastLoginInstant against cutoffs
# Count how many fall within each window
</code></pre>
<p dir="auto"><strong>If all time windows return 0 users</strong>: Nobody authenticated to that application during those periods, so the tokens weren't used.</p>
<p dir="auto"><strong>If users show up</strong>: The <code>lastLoginInstant</code> can't distinguish whether they used the token, password, or SSO. In this case, you have two additional options:</p>
<ol>
<li>
<p dir="auto"><strong>Check proxy/application logs</strong> for <code>/api/login</code> API calls and examine the request body to see if <code>loginId</code> and <code>password</code> were provided, or if it was a token-based authentication</p>
</li>
<li>
<p dir="auto"><strong>Check webhook events</strong>: If you have webhooks configured, examine <code>user.login.success</code> events for the <code>authenticationType</code> field. When a user authenticates with an application authentication token, the value will be <code>APPLICATION_TOKEN</code>. Other possible values include <code>PASSWORD</code>, <code>REFRESH_TOKEN</code>, identity providers like <code>GOOGLE</code> or <code>FACEBOOK</code>, and many more.</p>
</li>
<li>
<p dir="auto"><strong>Check JWTs</strong>: If you capture or log JWTs, the access token contains an <code>authenticationType</code> claim that indicates the authentication method used. For authentication tokens, this will be set to <code>APPLICATION_TOKEN</code>.</p>
</li>
</ol>
<h2>Related Documentation</h2>
<ul>
<li><a href="https://fusionauth.io/docs/lifecycle/authenticate-users/application-authentication-tokens" rel="nofollow ugc">Application Authentication Tokens</a> - Overview of application authentication tokens and how they work</li>
<li><a href="https://fusionauth.io/docs/apis/registrations/retrieve-a-user-registration" rel="nofollow ugc">Retrieve a User Registration API</a> - API documentation for retrieving user registration details including <code>authenticationToken</code> and <code>lastLoginInstant</code></li>
<li><a href="https://fusionauth.io/docs/apis/login/search" rel="nofollow ugc">Search Login Records API</a> - API for searching login records (note: does not include <code>authenticationType</code>)</li>
<li><a href="https://fusionauth.io/docs/extend/events-and-webhooks/events/user/login/user-login-success" rel="nofollow ugc">User Login Success Event</a> - Webhook event that includes <code>authenticationType</code> field</li>
<li><a href="https://fusionauth.io/docs/reference/authentication-types" rel="nofollow ugc">Authentication Types Reference</a> - Complete list of authentication types including <code>APPLICATION_TOKEN</code>, <code>PASSWORD</code>, and others</li>
<li><a href="https://fusionauth.io/docs/apis/login" rel="nofollow ugc">Login API</a> - API for authenticating users with various methods including authentication tokens</li>
</ul>
]]></description><link>https://fusionauth.io/community/forum/post/8994</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/8994</guid><dc:creator><![CDATA[FASupportBot]]></dc:creator><pubDate>Tue, 03 Nov 2026 22:46:31 GMT</pubDate></item></channel></rss>