The Play App Signing certificate fingerprint is in generatedapks.list — no need to open the Play Console

After the first release of an Android app on Google Play, I needed the SHA-256 fingerprint of the certificate Google signs the app with. Every guide says the same thing: open the Play Console, go to App signing, copy it. I wanted it from a script, with the service account I already use for uploads, and I assumed the API did not expose it. It does, in a resource I had never looked at.

TL;DR — generatedapks.list(packageName, versionCode) in the Android Publisher API v3 returns, for every APK set Play generated from your bundle, a certificateSha256Hash field. That is the Play App Signing certificate fingerprint. generatedapks.download hands you one of those APKs, and apksigner verify --print-certs on it prints the same fingerprint, so the value can be cross-checked without a browser.

The setup

The app uses Android App Links: an https:// link to the app’s domain opens the app directly instead of the browser. Android accepts that only if the domain publishes /.well-known/assetlinks.json listing the SHA-256 fingerprint of the certificate the installed app is signed with.

With Play App Signing, which is mandatory for new apps, there are two keys. The upload key lives on my machine and signs the bundle I send. Google then re-signs the app with the app signing key, and that is what devices install. An assetlinks.json that only lists the upload key works for sideloaded builds and silently fails for every Play Store install: the link opens in the browser.

Two keys sign the same app: the upload key you own signs the bundle sent to Play, Google's app signing key signs the APKs devices install. assetlinks.json must list the second one, and generatedapks.list is where the API reveals it.

The publishing pipeline is a Python script talking to the Android Publisher API through a service account. It pushes listings, uploads the bundle, assigns it to a track. I wanted the same script to fetch the fingerprint after the first release and merge it into assetlinks.json.

What I expected

The API reference has no « app signing » resource. I expected to either scrape the Console with a headless browser, which needs a logged-in Google session, or ask a human to paste the value. Neither is scriptable.

What actually happens

The generatedapks resource, which I had filed under « bulk APK download for testers », carries the answer. It is a top-level resource, not nested under edits, and it needs no open edit:

res = service.generatedapks().list(packageName=pkg, versionCode=10).execute()

The response for my single bundle:

generatedApks: 1
 certificateSha256Hash: 2E:5C:FA:EF:...:6D:27 | splits: 259 | universal: True

One entry per signing certificate, because Play keeps generated APKs grouped by the key that signed them. My first attempt used service.edits().generatedapks() and died with AttributeError: 'Resource' object has no attribute 'generatedapks'; the resource simply lives one level up.

To make sure the hash was the signing certificate and not, say, the bundle digest, I downloaded the base module’s master split and read its certificate:

from googleapiclient.http import MediaIoBaseDownload

dl = next(s["downloadId"] for g in res["generatedApks"]
          for s in g["generatedSplitApks"]
          if s["moduleName"] == "base" and not s.get("splitId"))
req = service.generatedapks().download_media(packageName=pkg, versionCode=10, downloadId=dl)
with open("play-signed-base.apk", "wb") as f:
    d = MediaIoBaseDownload(f, req)
    done = False
    while not done:
        _, done = d.next_chunk()

Then:

$ANDROID_HOME/build-tools/34.0.0/apksigner verify --print-certs play-signed-base.apk
# Signer #1 certificate DN: CN=Android, OU=Android, O=Google Inc., L=Mountain View, ST=California, C=US
# Signer #1 certificate SHA-256 digest: 2e5cfaef8424...6d27

Same fingerprint, and the distinguished name is Google’s, not mine. The split was 137 KB, which is expected: the master split of the base module holds the manifest and the dex, resources live in the other 258 splits.

The fix

The complete flow, from service account to fingerprint, is under twenty lines:

import os
from google.oauth2 import service_account
from googleapiclient.discovery import build

creds = service_account.Credentials.from_service_account_file(
    os.path.expanduser("~/.config/play/service-account.json"),
    scopes=["https://www.googleapis.com/auth/androidpublisher"])
service = build("androidpublisher", "v3", credentials=creds, cache_discovery=False)

pkg, version_code = "com.example.app", 10
res = service.generatedapks().list(packageName=pkg, versionCode=version_code).execute()
for group in res.get("generatedApks", []):
    print(group["certificateSha256Hash"])

I appended the value to the sha256_cert_fingerprints array in assetlinks.json next to the upload key’s fingerprint, redeployed, and asked Google’s own resolver whether it agreed:

curl -s 'https://digitalassetlinks.googleapis.com/v1/statements:list?source.web.site=https://example.com&relation=delegate_permission/common.handle_all_urls'

It returned two statements for the package, one per fingerprint, and an empty debugString.

Why it works

Play does not serve your bundle. At release time it derives a set of split APKs from it and signs each one with the app signing key. generatedapks.list is the inventory of exactly those files, so the certificate hash it reports is, by construction, the one Android will compute on the installed app and compare against assetlinks.json. There is no separate « signing key » endpoint because the generated artifacts already carry the information.

Keeping the upload key’s fingerprint in the file alongside it costs nothing and keeps App Links working for builds installed straight from the build machine.

What I did not test

I ran this once, on an app whose first production release had just completed. I do not know whether generatedapks.list returns anything while the release is still a draft, or how long after rollout the entry appears. The service account had release-management and store-presence permissions; I did not narrow them down to the minimum. I did not test an app whose signing key was rotated, where I would expect several generatedApks entries with different hashes, one per key, and only the newest one relevant for new installs.

Related: the Publisher API cannot make an app’s first release live, so this fingerprint only becomes available after that one manual step.

Facts

context: Android app with App Links, published on Google Play with Play App Signing, publishing scripted through the Android Publisher API v3 with a service account
problem: assetlinks.json needs the SHA-256 fingerprint of Google's app signing certificate, and the documented way to read it is the Play Console UI
solution: generatedapks.list(packageName, versionCode) returns certificateSha256Hash per generated APK set; generatedapks.download plus apksigner --print-certs confirms it
verified_on: 2026-09-05
applies_to: [Android Publisher API v3, google-api-python-client 2.x, apps with a completed release]
does_not_apply_to: [apps with no processed release yet (untested), key-rotation scenarios (untested)]

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Retour en haut