I have an App Engine Java application with billing enabled that I am now 
trying to integrate with Cloud Storage.  The idea is for the application to 
archive files in Cloud Storage when processing certain queue jobs.  I have 
gone over numerous pieces of documentation and followed directions as best 
I could, making use of Google Service Client and Storage JSON API client 
libraries,  I have created a single bucket so that the app create objects 
in it.  The problem is that I can't seem to establish trust between App 
Engine and the bucket.  Here is some relevant code:

            final Collection<String> scopes = 
Arrays.asList(StorageScopes.DEVSTORAGE_READ_WRITE);
            final String appName = "graph-wars";
            final HttpTransport transport = 
GoogleNetHttpTransport.newTrustedTransport();
            final JsonFactory jsonFactory = new JacksonFactory();
            final HttpRequestInitializer credential = new 
AppIdentityCredential(scopes);
            service = new Storage.Builder(transport, jsonFactory, 
credential)
                .setApplicationName(appName)
                .build();
...
        final HttpTransport transport = new UrlFetchTransport();
        final HttpRequest request = 
transport.createRequestFactory().buildGetRequest(new GenericUrl(new 
URL(url)));
        final HttpResponse response = request.execute();
        try
        {
            final StorageObject insertRequestObject = new StorageObject()
                .setBucket(bucketName)
                .setName(objectName)
                .setContentDisposition("attachment");
            final Storage service = getService();
            final Storage.Objects objService = service.objects();
            final Storage.Objects.Insert insertRequest = objService.insert(
                bucketName,
                insertRequestObject,
                new InputStreamContent(response.getContentType(), 
response.getContent())
            );
            final StorageObject insertedObject = insertRequest.execute();
        }
        finally
        {
            response.disconnect();
        }

I'm getting 403 response codes (seeing it with some debug println 
statements):

[s~graph-wars/69.392817061931109015].<stdout>: 
com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 
FORBIDDEN { "code" : 403, "errors" : [ { "domain" : "global", "message" : 
"Forbidden", "reason" : "forbidden" } ], "message" : "Forbidden" }

>From the console UI and documentation, it doesn't seem like I need to be 
doing anything special with the project or credential.  What am I missing?  
Any help would be appreciated.  Thanks!

-- 
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 [email protected].
To post to this group, send email to [email protected].
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/bfd4dae7-5536-4d93-b69e-1fbc3ca10f66%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
  • [google-appengine] u... 'Alexey' via Google App Engine

Reply via email to