title: Download generated APK using Google Play Android Developer API
body: <p>I have several packages in Google Play Store and deploy and publish the packages in bundles .abb format. I set the store to replace the signature of apps. We need to test applications with the final signature and sideload them to the device therefore we need apks and must download generated apks from the signed bundle from the google play store.</p>
  <p><a href="https://i.stack.imgur.com/6zSo1.png" rel="nofollow noreferrer">Google Play Store Console Download link lication</a></p>
  <p>We have an automation mechanism CI/CD and use Google API, the last step of this automation which is downloading the signed APK does not work!!!</p>
  <p>This is the ref link
  <a href="https://developers.google.com/android-publisher/download-apks" rel="nofollow noreferrer">https://developers.google.com/android-publisher/download-apks</a></p>
  <p><strong>Authentication scope</strong> <a href="https://www.googleapis.com/auth/androidpublisher" rel="nofollow noreferrer">https://www.googleapis.com/auth/androidpublisher</a></p>
  <p><strong>DownloadId extraction</strong>
  <a href="https://developers.google.com/android-publisher/api-ref/rest/v3/generatedapks/list" rel="nofollow noreferrer">https://developers.google.com/android-publisher/api-ref/rest/v3/generatedapks/list</a>
  <em>I need generatedUniversalApk</em></p>
  <p><strong>Template API request</strong></p>
  <p>GET <a href="https://androidpublisher.googleapis.com/androidpublisher/v3/applications/%7BpackageName%7D/generatedApks/%7BversionCode%7D/downloads/%7BdownloadId%7D:download" rel="nofollow noreferrer">https://androidpublisher.googleapis.com/androidpublisher/v3/applications/{packageName}/generatedApks/{versionCode}/downloads/{downloadId}:download</a></p>
  <p><strong>Example of API request</strong></p>
  <p>curl <br />
  --request GET 'https://androidpublisher.googleapis.com/androidpublisher/v3/applications/com.example.testapp/generatedApks/1234/downloads/MTszMjoyODpBRTo0RTpCRTozRjo4QjpBQjowRTpENTpGOTo2QjoxQzo5NjTRFgyhujrtVG6pBMjpFMDo0Qjo4Qzo1Qjo4MDo3refgGdFGrtyGFjoyNjpDRjoxNzpEMTtzcGxpdDsyO2Jhc2U=:download' <br />
  --header 'Authorization: Bearer ya29.c.b0AXv0zTPOHZXZLLV0HORNx6Ph_i0I5BSYGqHF55cB0g4t7SxlxlZvuiM0H6Ul8Wxu0a5YUcQBlrbV34MO3J65bvHHTYKfCNzQpqgnDGZ4Ag2apChnqmIKQEXslUnpVQWrtfghjdeZFbouN3ASJ2kdIBvK0N3_7ZApmuIyYs7E6DaJ8m6i94IznUbtSD8IGXVyMzhrYTRgFlCfoZhNvTjK0RjcY7Vp-qw</p>
  <p><em><strong>Issue</strong></em>
  It returns 204 and no download!!!
  I can download the signed APK from Google Play Console.</p>
  <p>It is another relevant question in the StackOverflow
  <a href="https://stackoverflow.com/questions/66796864/how-to-automate-download-google-signed-universal-apk-to-distribute-outside-googl">How to automate download Google signed universal APK to distribute outside Google Play?</a></p>