Skip to content

How to access GCS bucket from another project? #1073

Closed
@the1plummie

Description

@the1plummie

So I have files in a bucket BK1 created in gcloud project A, and I have appengine service running in project B. How do I configure BK1 bucket (or object) permissions so B's appengine service can access those files?

My sample code looks like this

        Storage storage = StorageOptions.defaultInstance().service();
        String filename = "foo.json";
        Blob blob = storage.get(BlobId.of("BK1", filename));
        if (blob == null) {
            return null;
        }
        System.out.println("blob content: " + new String(blob.content()));

I'm getting "login required" error.

I tried adding app engine default service account to BK1's permission, still not working either.
Any pointer would be appreciated.
Thx!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions