cloudyr / googleCloudStorageR

Google Cloud Storage API to R
https://code.markedmondson.me/googleCloudStorageR
Other
104 stars 29 forks source link

Demo listing buckets in a project doesn't work #5

Closed jarodmeng closed 8 years ago

jarodmeng commented 8 years ago

I tried the demo example to list buckets I have in my project, but was met with an API error.

library(googleCloudStorageR)
options(googleAuthR.scopes.selected =
  "https://www.googleapis.com/auth/devstorage.full_control")
googleAuthR::gar_auth()

proj <- "my project"

buckets <- gcs_list_buckets(proj)

The error says:

JSON fetch error: Access Not Configured. Cloud Storage JSON API has not been used in project 201908948134 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/storage_api/overview?project=201908948134 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.

It seems that 201908948134 refers to the default OAuth client in googleAuthR. Is it possible that the default client doesn't have Cloud Storage JSON API enabled and it's causing the error?

MarkEdmondson1234 commented 8 years ago

Yes it's not enabled for GoogleCloudSorage as it carries a charge and I don't want people to be able to charge my credit card :).

I need to update the docs to say that though - it should work once you use your own Google project keys and add a credit card to that. There is a guide to that in the googleAuthR readme that I will migrate to here soon. Let me know how it goes.

MarkEdmondson1234 commented 8 years ago

I have update the readme with the necessary information: https://github.com/cloudyr/googleCloudStorageR

jarodmeng commented 8 years ago

According to google cloud platform engineer, all API calls are charged to the account hosting the bucket. If an API call doesn't have a bucket element (such as listing all buckets in a project), it's charged to the account hosting the project. Since users of googleCloudStorageR will only be using their own projects/buckets in the API calls, I don't think your account would be charged.

Hadley's bigrquery uses the same approach and doesn't bother to ask end user to provide their own oauth app.

MarkEdmondson1234 commented 8 years ago

Ok cool, I've turned it back on then :)

jarodmeng commented 8 years ago

Confirmed it works now. Thanks.