Validate server-side verification (SSV) callbacks

  • Server-side verification callbacks notify an external system to reward a user for interacting with a rewarded ad, offering increased protection against spoofing compared to client-side methods.

  • This guide demonstrates verifying rewarded SSV callbacks using the Tink Java Apps library, though any third-party library supporting ECDSA can be used.

  • Rewarded SSV callbacks include various query parameters providing details about the ad interaction, including the ad unit, reward amount, and transaction ID.

  • Public keys required for verification can be fetched from the AdMob key server and should be cached but not for longer than 24 hours due to regular rotation.

  • The verification process involves parsing the callback URL to get the content to be verified, the signature, and the key ID, then using the appropriate public key to verify the signature against the content.


Server-side verification callbacks are URL requests, with query parameters expanded by Google, that are sent by Google to an external system to notify it that a user should be rewarded for interacting with a rewarded or rewarded interstitial ad. Rewarded SSV (server-side verification) callbacks provide an extra layer of protection against spoofing of client-side callbacks to reward users.

This guide shows you how to verify rewarded SSV callbacks by using the Tink Java Apps third-party cryptographic library to ensure that the query parameters in the callback are legitimate values. Although Tink is used for the purposes of this guide, you have the option to use any third-party library that supports ECDSA. You can also test your server with the testing tool in the AdMob UI.

Prerequisites

Use RewardedAdsVerifier from the Tink Java Apps library

The Tink Java Apps GitHub repository includes a RewardedAdsVerifier helper class to reduce the code required to verify a rewarded SSV callback. Using this class enables you to verify a callback URL with the following code.

RewardedAdsVerifier verifier = new RewardedAdsVerifier.Builder()
    .fetchVerifyingPublicKeysWith(
        RewardedAdsVerifier.KEYS_DOWNLOADER_INSTANCE_PROD)
    .build();
String rewardUrl = ...;
verifier.verify(rewardUrl);

If the verify() method executes without raising an exception, the callback URL was successfully verified. The Rewarding the user section details best practices regarding when users should be rewarded. For a breakdown of the steps performed by this class to verify rewarded SSV callbacks, you can read through the Manual verification of rewarded SSV section.

SSV callback parameters

Server-side verification callbacks contain query parameters that describe the rewarded ad interaction. Parameter names, descriptions, and example values are listed below. Parameters are sent in alphabetical order.

Parameter Name Description Example value
ad_network Ad source identifier for the ad source that fulfilled this ad. Ad source names corresponding to ID values are listed in the Ad source identifiers section. 1953547073528090325
ad_unit AdMob ad unit ID that was used to request the rewarded ad. 2747237135
custom_data Custom data string as provided by ServerSideVerificationOptions::custom_data.

If no custom data string is provided by the app, this query parameter value will not be present in the SSV callback.

SAMPLE_CUSTOM_DATA_STRING
key_id Key to be used to verify SSV callback. This value maps to a public key provided by the AdMob key server. 1234567890
reward_amount Reward amount as specified in the ad unit settings. 5
reward_item Reward item as specified in the ad unit settings. coins
signature Signature for SSV callback generated by AdMob. MEUCIQCLJS_s4ia_sN06HqzeW7Wc3nhZi4RlW3qV0oO-6AIYdQIgGJEh-rzKreO-paNDbSCzWGMtmgJHYYW9k2_icM9LFMY
timestamp Timestamp of when the user was rewarded as Epoch time in ms. 1507770365237823
transaction_id Unique hex encoded identifier for each reward grant event generated by AdMob. 18fa792de1bca816048293fc71035638
user_id User identifier as provided by ServerSideVerificationOptions::user_id.

If no user identifier is provided by the app, this query parameter will not be present in the SSV callback.

1234567

Ad source identifiers

Ad source names and IDs

Ad source name Ad source ID
Ad Generation (bidding)1477265452970951479
AdMob Network5450213213286189855
AdMob Network Waterfall1215381445328257950
AppLovin1063618907739174004
AppLovin (bidding)1328079684332308356
Bidease (bidding)3670825090829827805
BidMachine (bidding)7943972370566394673
Chartboost2873236629771172317
Chocolate Platform (bidding)6432849193975106527
Custom Event18351550913290782395
DT Exchange*

* Prior to September 21, 2022, this network was called "Fyber Marketplace".

2179455223494392917
DT Exchange (bidding)8189833498765234879
Equativ (bidding)*

* Prior to January 12, 2023, this network was called "Smart Adserver".

5970199210771591442
Fluct (bidding)8419777862490735710
i-mobile5208827440166355534
Improve Digital (bidding)159382223051638006
Index Exchange (bidding)4100650709078789802
InMobi7681903010231960328
InMobi (SDK) (bidding)8468954295581492586
InMobi Exchange (bidding)5264320421916134407