Firebase Callable Function 'UNAUTHENTICATED' in Flutter? The 5-Step Method to Find What's Rejecting the Call

By · Published 2026-11-20 · Last verified 2026-11-20

Why does Flutter get "UNAUTHENTICATED" from a callable Cloud Function?

Because the callable protocol rejected the request: if the Firebase Authentication token sent with the call is invalid, the backend answers with HTTP 401 Unauthorized and the error code UNAUTHENTICATED. GSPTeck is giosaia's indie studio building mobile and web apps with Flutter and Firebase, and this is the callable case, not a Cloud Storage or Firestore rules denial. The same symptom can also mean the client pointed at the wrong region, App Check enforcement rejected the request, or Cloud Run IAM never let the invocation through. The 5-step method below tells those apart, using Firebase and Google Cloud documentation checked on 2026-11-20.

Grid of the 5-step method for a Firebase callable UNAUTHENTICATED error in Flutter: print the error code, confirm the signed-in user, set the same region as the deployed function, check App Check enforcement, and separate Cloud Run invoker IAM from Firebase Auth
The 5-step method to find what rejected the callable.

Which rejection do you actually have?

Read the error code first. Firebase's protocol for HTTPS callable functions lists exact status codes, and they do not all mean the same fix. An invalid Auth token is UNAUTHENTICATED. A missing signed-in user is not automatically that code: official callable samples throw FAILED_PRECONDITION when request.auth is null. App Check and IAM failures can stop the request before your function body runs.

What you seeWhat the docs say it meansWhere to look
UNAUTHENTICATED (HTTP 401)The Auth token supplied in the request is invalid, so the request is rejectedThe user's ID token, sign-in state, and clock
FAILED_PRECONDITION from your functionOfficial samples throw this when request.auth is null, if you required a signed-in userYour function code, not the protocol itself
Rejected with App Check enforcement onenforceAppCheck: true rejects requests with a missing or invalid App Check tokenApp Check in the app and the function options
Wrong regionTo call a function outside us-central1, you must set that region when you initialize the client SDKThe region you deployed to vs the region the app uses
Cloud Run IAM denial2nd gen functions run on Cloud Run; access can require the roles/run.invoker binding, including allUsers in Google's IAM examplesThe function's IAM policy, not Firebase Auth users
Two columns comparing an invalid Firebase Auth token, which the callable protocol rejects as 401 UNAUTHENTICATED, with a request that never reaches the function because of App Check enforcement, a region mismatch, or Cloud Run invoker IAM
Protocol rejection, or the request never arrived.

The 5-step method to find what's rejecting the call

This is the Callable Rejection Check: one ordered pass that starts with the error code and only then changes configuration. Change one thing at a time so you know which check actually fixed it.

  1. Print the full error. Log the code, message and HTTP status. You are looking for UNAUTHENTICATED and 401, not a generic timeout or NOT_FOUND.
  2. Confirm the signed-in user. If your function expects a user, the client must be signed in and sending a valid ID token. Callable functions include the Firebase Authentication token automatically when one is available, and the trigger validates it.
  3. Point the client at the same region you deployed. Firebase's callable documentation says that if the function is not in us-central1, you must set the correct value at initialization.
  4. Check App Check enforcement. If the function sets enforceAppCheck: true, missing or invalid App Check tokens are rejected. The Cloud Functions client SDKs attach an App Check token when you invoke a callable.
  5. Separate Cloud Run invoker IAM from Firebase Auth. Granting roles/run.invoker to allUsers is a Google Cloud IAM setting that allows the endpoint to be invoked. It is not the same as a Firebase Auth user. Inside the function, still check request.auth for your own access rules.

Do not "fix" this by opening the function to everyone in your own code with no Auth check. IAM and App Check are abuse controls; they are not a replacement for checking the signed-in user when the action should be private. The same studio's notes on App Check in staging and on the requires-recent-login Auth error cover those neighbouring problems without mixing them up.

What "invalid Auth token" actually covers

The callable protocol says the optional Authorization: Bearer header carries a Firebase Authentication user ID token. If that token is not valid, the request is rejected. That includes an expired token the client did not refresh, a token from a different Firebase project, or a request that presents a malformed credential. It is not the same error as Cloud Storage storage/unauthorized, which is a security-rules denial; for that case see how to find the Storage rule that says no.

If nobody is signed in, there may be no Auth token at all. The protocol treats the header as optional. Your function can still refuse the call when request.auth is null, but the code you throw is the one you choose; the official samples use FAILED_PRECONDITION for "must be called while authenticated." If you expected UNAUTHENTICATED in that situation and got a different code, read your function, not only the client.

Region, App Check and IAM, in that order

A region mismatch looks like a broken function, not a user problem. Deployments to europe-west1 or another region will not be called by a client that still talks to the default us-central1. Set the region once, in the same place you initialize Firebase Functions, and keep it in source control so a new flavour of the app does not silently drop it.

App Check is next because enforcement is a function option, not a client-only setting. Firebase's App Check guide for callable functions says that after you enable enforcement, unverified requests are rejected, and that the client SDKs attach a token automatically when you invoke a callable. A debug build that never registered an App Check debug token will fail here, even with a perfectly valid signed-in user.

Four boxes for callable rejections after Auth: a region mismatch with us-central1, App Check enforceAppCheck rejecting a missing token, Cloud Run invoker IAM, and a function that throws FAILED_PRECONDITION when request.auth is null
Four checks once the Auth token is valid.

IAM is last because it is easy to misread. Google Cloud's documentation for Cloud Run functions shows binding roles/run.invoker to allUsers after deployment. That Google Cloud member is not a Firebase Auth user. If IAM blocks the request, your function logs may never show the call. If IAM allows it, you still decide in code whether an unauthenticated Firebase user may do the work. For a broader release pass, use the Flutter Firebase release checklist before you ship the build that first talks to a new callable. If users can't sign in at all before calling your function, see how to handle invalid-credential instead of user-not-found in Flutter.

FAQ

Does UNAUTHENTICATED mean my Security Rules are wrong?

No. Security Rules apply to Cloud Firestore, Realtime Database and Cloud Storage, not to the callable protocol's Auth-token check. A callable can still read Firestore with the Admin SDK after it has accepted the request, but the 401 you see at the client is the callable handshake, not a rules deny.

Do I have to sign in to call a callable function?

Only if your function requires it. The Auth header is optional in the protocol. If the function does not check request.auth, a signed-out client can still invoke it, subject to App Check and IAM. If the action is private, check request.auth in the function and handle a missing user explicitly.

Why does it work in the emulator but fail in production?

The production function has a real region, real App Check enforcement, real IAM and real Auth tokens from your Firebase project. An emulator setup can hide all four. Compare the region you initialize, whether enforceAppCheck is on in the deployed function, and whether the production identity is from the same project.

Is granting Cloud Run invoker to allUsers the same as making the function public to every Firebase user?

No. That IAM binding lets the HTTPS endpoint be invoked without a Google Cloud identity. Firebase Authentication is still a separate token, automatically included when the user is signed in, and your function can still refuse request.auth == null.

Sources

Vertical Pinterest graphic with five checks for a Firebase callable UNAUTHENTICATED error in Flutter
Pinterest pin: callable UNAUTHENTICATED in Flutter.