Provided that you are using the Endpoints client library that you generated 
for Android 
<https://cloud.google.com/endpoints/docs/frameworks/java/generate-client-libraries-android>,
 
it's not necessary to manually add the headers yourself. You need to 
configure the client library to authenticate, and the full instructions for 
this are provided in the documentation Calling Backend APIs from an Android 
Client 
<https://cloud.google.com/endpoints/docs/frameworks/java/calling-from-android>
.

On Monday, March 27, 2017 at 2:20:46 PM UTC-4, Cristina De Rito wrote:
>
> I have a problem restricting a Google Cloud Platform API key usage to an 
> Android app: I have added its package name and certificate SHA-1 
> fingerprint (the debug one to get started) but it doesn't work.
>
> <https://i.stack.imgur.com/jBhzK.png>
>
>
> The error I get when calling any API is
>
> 403 Requests from this Android client application <empty> are blocked.
>
> I'm calling the APIs by using a Cloud Endpoints generated client lib, and 
> I've not been able to find any method that I can use at initialisation time 
> to set the app credentials, nor does it do it by itself (as I can guess 
> from the "<empty>" in the error). I can't find any useful info in any 
> documentation as well, as far as I've red it seems like it should do it by 
> itself.
>
> This is my init code:
>
> MyApi.Builder builder = new MyApi.Builder(new NetHttpTransport(), new 
> AndroidJsonFactory(), null)
>                 .setApplicationName("<my package name>")
>                 .setRootUrl(<my root URL>)
>                 .setGoogleClientRequestInitializer(new 
> MyApiRequestInitializer(<my API key>));
>
> I've also tried what suggested in this answer 
> <http://stackoverflow.com/a/42851756/5219866> but nothing changed.
>
> Is there any passage I'm missing? How should it be done?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/5ffe2acf-1437-48b2-832a-2c278ed37ed7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to