Protect custom backend resources with App Check in C++ projects

You can useApp Check to protect non-Google custom backend resources foryour app, like your own self-hosted backend. To do so, you'll need to do both ofthe following:

  • Modify your app client to send an App Check token along with each requestto your backend, as described on this page.
  • Modify your backend to require a valid App Check token with every request,as described inVerify App Check tokens from a custom backend.

Before you begin

Add App Check to your app, using thedefault providers.

Send App Check tokens with backend requests

To ensure your backend requests include a valid, unexpired, App Check token,precede each request with a call toAppCheck::GetAppCheckToken(). The AppCheck library will refresh the token if necessary.

Once you have a valid token, send it along with the request to your backend. Thespecifics of how you accomplish this are up to you, butdon't sendApp Check tokens as part of URLs, including in query parameters, as thismakes them vulnerable to accidental leakage and interception. The recommendedapproach is to send the token in a custom HTTP header.

For example:

voidCallApiExample(){firebase_app_check::AppCheck*app_check=firebase::app_check::AppCheck::GetInstance();Future<std::string>app_check_future=app_check->GetAppCheckToken(false);app_check_future.OnCompletion([&](constFuture<std::string>&future_token){if(future_token.result()){// Got a valid App Check token. Include it in your own http calls.}}}

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-17 UTC.