1

So I am consuming the Google Link Shortener API. I have created an API Key for access in the Developer Console. When the API has no restrictions, then I am able to call it and get the result, but when I restrict the key with my android package name and SHA-1 then it gives an error The request did not specify any Android package name or signing-certificate fingerprint. Please ensure that the client is sending them or use the API Console to update your key restrictions. Although I am sending the request from the Android app. I am using retrofit for networking.

Do i have to explicitly specify the package name? and so then how?

Gurleen Sethi
  • 3,162
  • 6
  • 26
  • 48
  • refer http://stackoverflow.com/questions/39543105/youtube-api-key – sasikumar Mar 30 '17 at 06:21
  • are you using the unsigned apk for build or getting the error in released one ? – Shubhank Mar 30 '17 at 06:27
  • using the unsigned apk – Gurleen Sethi Mar 30 '17 at 06:32
  • and the hash you added in the developer console is also of the debug keystore right ? – Shubhank Mar 30 '17 at 06:34
  • I am generating the key using `keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android` – Gurleen Sethi Mar 30 '17 at 06:37
  • according to [this](http://stackoverflow.com/a/42851756) you have to have the package name and SHA in the request header. Probably retrofit isn't sending this. Try checking out other samples on the net or maybe just turning off restrictions in console – Shubhank Mar 30 '17 at 06:41

1 Answers1

0

The problem was I didn't had the SHA-1 of the keystore in my Google API Console.

Just to clear up guys. When you generate a signed apk, it is signed with a different SHA-1 key than your debug SHA-1 key, so be sure to also add the SHA-1 from the keystore you have signed with.

You can get the SHA-1 from the keystore by this command : keytool -list -v -keystore keystorename.jks -alias myaliasname

Gurleen Sethi
  • 3,162
  • 6
  • 26
  • 48