How to fix App Check: Token Validation Failed in Firebase

FirebaseINTERMEDIATEHIGHUpdated Dec 29, 2025· 384 views

This error occurs when Firebase App Check cannot verify the authenticity of requests to your Firebase services. Token validation failures can stem from misconfigured providers, server time mismatches, expired tokens, or incorrect app registration.

Quick fix

Fixes App Check: Token Validation Failed

# Get SHA-1 fingerprint
   ./gradlew signingReport

   # Or using keytool
   keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
  1. Verify your app is registered in Firebase Console
  2. Configure the correct attestation provider
  3. Use debug tokens for local development
  4. Synchronize server and device clocks
firebase — error
# Get SHA-1 fingerprint
./gradlew signingReport
# Or using keytool
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
App Check: Token Validation Failed

What this error means

The "App Check: Token Validation Failed" error indicates that Firebase App Check is unable to authenticate and verify that requests are coming from a legitimate instance of your app. This security check validates that requests originate from your app running on a registered device with proper attestation from the platform provider (Play Integrity, SafetyNet, DeviceCheck, or reCAPTCHA). App Check works by having your client app generate a token from its attestation provider before making requests. Your backend then verifies this token is legitimate by checking its signature, expiration, and other claims. When verification fails, it means either the token is malformed, the app isn't properly registered, or the attestation provider couldn't verify the app's authenticity. This is a critical error because it blocks legitimate app access to your Firebase resources as a security measure.

Typical symptoms

  • Backend API calls return 401 Unauthorized or 403 Forbidden
  • Cloud Functions fail with App Check token invalid errors
  • Firestore/Realtime Database reject writes with permission errors
  • Error occurs after deploying App Check enforcement
  • Token verification succeeds in development but fails in production
  • All users experience token validation failures at the same time
  • Errors appear after app updates or Firebase Console configuration changes

Common causes

  1. App hasn't been registered in Firebase Console with correct package name or bundle ID
  2. SHA-1 or SHA-256 certificate fingerprints don't match those registered in Firebase
  3. Attestation provider (Play Integrity, DeviceCheck, SafetyNet) is not properly configured
  4. Device clock is significantly out of sync with server, causing token timestamp validation to fail
  5. Token has expired before backend verification attempts
  6. Debug token is not registered in Firebase Console for development
  7. Configuration changes haven't propagated through Firebase's systems (15-30 minute delay)
  8. Using debug/test APK without proper Play Store signing
  9. JWKS endpoint is rate-limited or unreachable from your backend
  10. Token is incomplete or corrupted during transmission

How to fix "App Check: Token Validation Failed"

1Verify your app is registered in Firebase Console

First, ensure your app is properly registered with the correct identifiers:

1. Open [Firebase Console](https://console.firebase.google.com/)
2. Navigate to your project → Project Settings
3. Verify your app is listed with the correct:
- Package name (Android): Exact match, case-sensitive
- Bundle ID (iOS): Exact match, case-sensitive
- App ID (Web): Present and accessible

4. For Android, verify certificate fingerprints:

bash
# Get SHA-1 fingerprint
   ./gradlew signingReport

   # Or using keytool
   keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android

5. Compare the output with what's registered in Firebase Console → App Check tab

If the app doesn't appear in Firebase Console, add it:
- Click "Add app" in Project Settings
- Select your platform (Android/iOS/Web)
- Enter the exact package name/bundle ID
- For Android: Add both SHA-1 and SHA-256 fingerprints

2Configure the correct attestation provider

App Check uses platform-specific attestation providers. Ensure the right one is configured:

For Android:
- Recommended: Play Integrity API (modern replacement for SafetyNet)
- Requires linking Firebase to Google Play Console
- Provides robust device verification

- Alternative: SafetyNet Attestation API (deprecated but still works)

For iOS:
- Recommended: App Attest (iOS 14.0+)
- Hardware-based attestation with no server calls needed

- Alternative: DeviceCheck (iOS 11.0+)
- Server-based device verification

For Web:
- Only option: reCAPTCHA v3
- Requires reCAPTCHA v3 API key configured

To configure in Firebase Console:
1. Go to App Check tab
2. Click "Manage" on your app
3. Select the appropriate provider
4. Follow provider-specific setup instructions

Example Web setup:

javascript
import { initializeAppCheck, ReCaptchaV3Provider } from "firebase/app-check";

initializeAppCheck(app, {
  provider: new ReCaptchaV3Provider("YOUR_RECAPTCHA_V3_PUBLIC_KEY"),
  isTokenAutoRefreshEnabled: true
});

Example Android setup:

kotlin
val playIntegrityProvider = PlayIntegrityAppCheckProviderFactory.getInstance()
FirebaseAppCheck.getInstance().installAppCheckProviderFactory(playIntegrityProvider)
3Use debug tokens for local development

Development builds often can't generate valid production tokens. Use debug tokens instead:

1. In Firebase Console → App Check → Manage App:
- Enable "App Check Debug Provider"
- Copy the debug token

2. Register the debug token in your app:

Web:

javascript
// Call BEFORE initializing Firebase
self.FIREBASE_APPCHECK_DEBUG_TOKEN = "YOUR_DEBUG_TOKEN_HERE";

// Or set it dynamically
if (process.env.NODE_ENV === 'development') {
  self.FIREBASE_APPCHECK_DEBUG_TOKEN = "YOUR_DEBUG_TOKEN";
}

Android:

kotlin
// In onCreate of your Application class
FirebaseAppCheck.getInstance().installAppCheckProviderFactory(
  DebugAppCheckProviderFactory()
)

iOS:

swift
#if DEBUG
  let debugProvider = AppCheckDebugProviderFactory()
  AppCheck.setAppCheckProvider(debugProvider)
#else
  // Use production provider
  let deviceCheckProvider = DeviceCheckProvider()
  AppCheck.setAppCheckProvider(deviceCheckProvider)
#endif

Important: Debug tokens only work during development. Remove debug provider code before deploying to production.

4Synchronize server and device clocks

Token validation includes timestamp checks. Clock skew causes "token not yet valid" errors:

Check your device time:

bash
# On Android device
adb shell date

# On iOS, check Settings → General → Date & Time
# Ensure "Set Automatically" is enabled

Check your backend server time:

bash
# On your server/Cloud Function
date -u
timedatectl status  # On Linux

If times differ by more than a few seconds:

For development devices:
- Ensure NTP time sync is enabled
- Manually set correct time

For servers:
- Check NTP daemon is running
- Verify timezone is correct
- For Cloud Functions: Usually auto-synced, but check region

For testing:
- Temporarily disable token validation in development
- Use Firebase Rules with request.firebaseAppCheck.token.claims.app_id to debug

Example with detailed error logging:

javascript
try {
  const decodedToken = await admin.appCheck().verifyIdToken(appCheckToken);
  console.log("Token verified:", decodedToken);
} catch (error) {
  console.error("Token verification failed:", error.message);
  console.error("Error code:", error.code);
  // "The token is not yet valid (iat)" indicates clock skew
}
5Verify token generation and transmission

Ensure tokens are properly generated and sent to your backend:

Client-side token generation:

Web:

javascript
import { getAppCheck, getToken } from "firebase/app-check";

const appCheck = getAppCheck();
const { token } = await getToken(appCheck, /* forceRefresh */ true);
// token is the complete JWT string

Android:

kotlin
val appCheck = FirebaseAppCheck.getInstance()
appCheck.getAppCheckToken(false)
  .addOnSuccessListener { result ->
    val token = result.token
    // Use this complete token
  }

Sending to backend:
- Send the ENTIRE token string (not decoded)
- Include in Authorization header or custom header
- Don't truncate or modify the token

javascript
fetch('/api/protected', {
  headers: {
    'X-Firebase-AppCheck': token  // Send complete token
  }
})

Backend verification:

javascript
// Node.js with Firebase Admin SDK
const appCheckToken = req.headers['x-firebase-appcheck'];

try {
  const decodedToken = await admin.appCheck().verifyIdToken(appCheckToken);
  // Token is valid, proceed with request
} catch (error) {
  console.error('Invalid token:', error.message);
  res.status(401).send('App Check token validation failed');
}

Common mistakes:
- Sending only part of the token
- URL-encoding or base64-encoding the token
- Forgetting to pass the entire string

6Wait for Firebase configuration propagation

Configuration changes in Firebase Console take time to propagate globally:

After any of these actions, wait 15-30 minutes before testing:
- Adding a new app
- Registering certificate fingerprints
- Enabling App Check enforcement
- Changing attestation providers
- Updating provider configuration

During this window:
- Some regions may have old configuration
- Token validation may be inconsistent
- Errors like "app not found" may occur

To verify propagation is complete:

1. Test from multiple locations/networks
2. Check Firebase Console → App Check → Usage metrics
3. Monitor Cloud Functions logs for patterns in validation failures

If errors persist after 30 minutes:
- Try disabling and re-enabling App Check
- Delete and re-add your app in Firebase
- Clear app cache on test devices

bash
# Clear Android app cache
adb shell pm clear com.example.myapp

# Clear iOS app cache
# Settings → General → iPhone Storage → [App] → Offload App (then reinstall)
7Verify JWKS endpoint accessibility

Backend token verification fetches the public key set from Google's JWKS endpoint:

The endpoint is: https://firebaseappcheck.googleapis.com/v1/jwks

Test endpoint accessibility:

bash
# From your backend/server
curl -I https://firebaseappcheck.googleapis.com/v1/jwks

# Should return 200 OK
# If you get 403, Google may be rate-limiting your backend IP

Rate limiting issues:
If your backend gets 403 Forbidden from the JWKS endpoint, add authentication:

javascript
// Use an API key to bypass rate limits
const response = await fetch(
  'https://firebaseappcheck.googleapis.com/v1/jwks?key=YOUR_API_KEY',
  {
    headers: {
      'X-goog-api-key': 'YOUR_API_KEY'
    }
  }
);

Get your API key from Firebase Console → Project Settings → API keys

Firewall/network issues:
- Ensure your backend can reach Google APIs
- Check VPC/security group rules allow outbound HTTPS
- Verify no proxy is blocking the request
- Try from different network to isolate issue

8Check Firestore/Realtime Database security rules

App Check claims must be accessed correctly in security rules:

Firestore Rules:

bash
match /databases/{database}/documents {
  match /protected/{document=**} {
    allow read, write: if request.firebaseAppCheck.token != null;
  }
}

Realtime Database Rules:

json
{
  "rules": {
    "protected": {
      ".read": "auth.uid != null && newData.val().appCheck != null",
      ".write": "auth.uid != null && newData.val().appCheck != null"
    }
  }
}

Debugging rules:

bash
match /test/{doc} {
  allow read: if debug(request.firebaseAppCheck.token != null);
}

Common errors:
- Rule expects App Check but client didn't provide token
- App Check enabled on backend but not enforced in rules
- Token expired by the time rule is evaluated

Test with simulator first, then deploy gradually to users.

Advanced notes

How App Check token validation works: When a client app makes a request, it first obtains a token from the platform's attestation provider (Play Integrity, DeviceCheck, etc.). This token confirms the app is legitimate and running on a real device. Your backend then verifies this token by fetching the JWKS public key set, checking the signature with RS256 algorithm, and validating claims like iss (issuer), aud (audience), iat (issued time), and exp (expiration).

Token lifetime: App Check tokens are short-lived (typically 1 hour). They're automatically refreshed by the SDK, but in low-network conditions or long operations, tokens may expire. Use getToken(appCheck, true) to force a fresh token if needed.

Attestation provider differences: Play Integrity and DeviceCheck return immediate tokens and are faster. SafetyNet may have network latency. reCAPTCHA v3 is asynchronous and may delay requests. Choose based on your app's UX requirements.

Testing in production: To safely roll out App Check, use Firebase's gradual enforcement option. Start with logging-only (no enforcement), monitor success rates, then enable enforcement percentage-by-percentage. This prevents blocking all users if there's a configuration issue.

Disabling for specific routes: If certain Cloud Functions don't need App Check, omit the verification check for those endpoints. This is useful for public-facing functions or those called from web browsers where reCAPTCHA setup is complex.

Custom authentication backends: If using a custom JWT backend instead of Firebase Auth, you still need App Check tokens. Include both in your request: the user's auth token AND the App Check token in separate headers.

Frequently asked questions

What does "App Check: Token Validation Failed" mean?
The "App Check: Token Validation Failed" error indicates that Firebase App Check is unable to authenticate and verify that requests are coming from a legitimate instance of your app. This security check validates that requests originate from your app running on a registered device with proper attestation from the platform provider (Play Integrity, SafetyNet, DeviceCheck, or reCAPTCHA). App Check works by having your client app generate a token from its attestation provider before making requests.
How do I fix "App Check: Token Validation Failed"?
This error occurs when Firebase App Check cannot verify the authenticity of requests to your Firebase services. Token validation failures can stem from misconfigured providers, server time mismatches, expired tokens, or incorrect app registration.
What causes "App Check: Token Validation Failed"?
App hasn't been registered in Firebase Console with correct package name or bundle ID SHA-1 or SHA-256 certificate fingerprints don't match those registered in Firebase Attestation provider (Play Integrity, DeviceCheck, SafetyNet) is not properly configured
Is the "App Check: Token Validation Failed" error serious?
Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.

Official resources & further reading