I am trying to create a GCS bucket using the JAVA Api from an App Engine project.
I get the following error with not much further information.
403 FORBIDDEN { "code" : 403, "errors" : [ { "domain" : "global", "message" : "Forbidden", "reason" : "forbidden" } ], "message" : "Forbidden" }
Based on reading up on internet, I have already checked the following
Enable Billing - Done.. Enable GoogleCloudStorage API - Done ..
Inspite of doing these, I see the error.
This is how I am creating the storage object ---
httpTransport = GoogleNetHttpTransport.newTrustedTransport();
JSON_FACTORY = JacksonFactory.getDefaultInstance();
credential = GoogleCredential.getApplicationDefault();
//Add Scopes
List<String> colls = new ArrayList<String>();
colls.addAll(StorageScopes.all());
if (credential.createScopedRequired()) {
credential = credential.createScoped(colls);
}
//Build storage
storage = new Storage.Builder(httpTransport, JSON_FACTORY, credential).setApplicationName("projectName").build();
Bucket newBucket = storage.buckets().insert("projectName", new Bucket()
.setName(bktName).setLocation("US")).execute();
The same code used to work in a different project. However, I am unable to create buckets with a 403 error on a new project that I have created..
Hope to hear something from you guys soon !!!
Thanks,
Srikanth