Abbas
Abbas

Reputation: 3331

Unable to Restrict YouTube Data API key to Android App

As the title says I'm having trouble restricting use of the YouTube Data API key by Android App.

What I've done so far:

Obtaining SHA-1 Fingerprint:

I now believe I've completed all the steps as outlined in the Applying API Key Restrictions - Google Cloud Platform page. However YouTube Data API calls are still failing with 403. Am I missing something?

Here is my request from debug app: I realize that should fail expectedly but I can't turn on network logging for the current app without pushing an app update.

GET: https://www.googleapis.com/youtube/v3/videos?part=snippet&id=Mkq8pnvsnQg&key=API_KEY

One thing I've noticed is that there are no Android app identifying markers present i.e. no way to tell if it the request was made from Android or any other platform, so maybe I'm missing something there?

Upvotes: 4

Views: 569

Answers (1)

Pavlo Ostasha
Pavlo Ostasha

Reputation: 16699

You won't be able to use the API with restricted access from a debug app. When it is uploaded to the device - it is signed with a development key which SHA1 is different from the one you use on playstore.

You should add one more SHA1 key to the restriction list - your development key. Here is how to do it. Only after that, you will be able to use it on the debug app.

You can also app debuggable = true and minifiedEnabled = false to the release build variant settings in Gradle in order to be able to debug of release app - just don't forget to change it back before submitting to play store.

If you are still not able to use the app even on release build signed with the correct certificate - it means that either you have entered the wrong SHA1 and the wrong package name or did not provided all the needed scopes to the Google Sign-in.

Upvotes: 1

Related Questions