Authorizing local App Engine app to access Cloud Storage

9 views
Skip to first unread message

Orbit via StackOverflow

unread,
Mar 10, 2017, 1:57:04 AM3/10/17
to google-appengin...@googlegroups.com

I'm developing and testing an App Engine application locally. I would like the application to print out a list of all Bucket names in the projects Google Cloud Storage.

Some code:

Storage storage = StorageOptions.getDefaultInstance().getService();
Page<Bucket> buckets = storage.list(Storage.BucketListOption.pageSize(100));
Iterator<Bucket> bucketIterator = buckets.iterateAll();
while (bucketIterator.hasNext()) {
    Bucket bucket = bucketIterator.next();
    System.out.println("bucket name: " + bucket.getName());
}

To access Cloud Storage, I am using the google-cloud library for Java found here: http://googlecloudplatform.github.io/google-cloud-java/0.9.4/index.html

Running the above snippet results in a 401 Unauthorized.

As specified under the "What is it?" section in the above link, if the application is running inside App Engine or Compute Engine, authentication is automatic.

Since I am running locally, I assume automatic authentication does not work (please correct me if i'm wrong).

To authenticate, I followed one of the options listed under the Authentication section and issued the command gcloud auth application-default login in the terminal.

I no longer get a 401 unauthorized when trying to access Cloud Storage, however do get the following:

java.security.AccessControlException: access denied ("java.io.FilePermission" "/Users/example/.config/gcloud/active_config" "read")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472)
at java.security.AccessController.checkPermission(AccessController.java:884)
  1. How can I resolve this AccessControlException?
  2. Is this the correct way to authenticate to Cloud Storage while developing locally? If not, what is?


Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/42712134/authorizing-local-app-engine-app-to-access-cloud-storage
Reply all
Reply to author
Forward
0 new messages