Ahsan.Amin
Ahsan.Amin

Reputation: 784

Google cloud storage objective c sample

I got the Google API for Objective C for using Cloud Storage Module from below path.

Google API Objective-C Client

Unluckily the api didn't provide any Sample Code for Cloud Storage so I tried to do it myself but I couldn't be successful. Below is what I am doing

  1. I enabled my billing for Cloud Storage from Google API Console
  2. I made a bucket with name "ahs_test"
  3. I made a Client ID for installed applications
  4. I got successful with Outh2.0 with the library available at upper SVN Path. After doing this I wrote below code and get below error message
  5. Note that After reading Google Cloud Storage I am sort of sure that I have to send the "x-goog-project-id" in my request header but I am wondering that this API's code doesn't do anything like that. ( I might be doing some mistake so leaving this for getting any sort of help.. Thanks in Advance...)

// Code....

GTLServiceStorage *service = self.storageService
GTLQueryStorage *query = [GTLQueryStorage queryForBucketsGetWithBucket:@"ahs_test"];
_fileListTicket = [service executeQuery:query
completionHandler:^(GTLServiceTicket *ticket,
                                        GTLStorageBuckets  *bucketList,
                                        NSError *error) {

}];

// Error Message I get (Detailed from loger)

storage.buckets.get

2012-12-30 07:11:30 +0000
Request: POST https://www.googleapis.com/rpc?prettyPrint=false
Request headers:
  Accept: application/json-rpc
  Authorization: Bearer _snip_
  Cache-Control: no-cache
  Content-Type: application/json-rpc; charset=utf-8
  User-Agent: com.example.DriveSample/1.0 google-api-objc-client/2.0 MacOSX/10.8 (gzip)

Request body: (128 bytes)
{
  "jsonrpc" : "2.0",
  "method" : "storage.buckets.get",
  "id" : "gtl_3",
  "params" : {
    "bucket" : "ahs_test",
    "max-results" : 150
  },
  "apiVersion" : "v1beta1"
}

Response: status 200
Response headers:
  Cache-Control: no-cache, no-store, max-age=0, must-revalidate
  Content-Encoding: gzip
  Content-Length: 132
  Content-Type: application/json; charset=UTF-8
  Date: Sun, 30 Dec 2012 07:10:44 GMT
  Expires: Fri, 01 Jan 1990 00:00:00 GMT
  Pragma: no-cache
  Server: GSE
  X-Content-Type-Options: nosniff
  X-Frame-Options: SAMEORIGIN
  X-XSS-Protection: 1; mode=block

Response body: (168 bytes)
{
  "error" : {
    "message" : "Access Not Configured",
    "data" : [
      {
        "reason" : "accessNotConfigured",
        "message" : "Access Not Configured",
        "domain" : "usageLimits"
      }
    ],
    "code" : 403
  },
  "id" : "gtl_3"
}

Upvotes: 2

Views: 1261

Answers (1)

Brian Dorsey
Brian Dorsey

Reputation: 4688

The Google API library uses the Cloud Storage JSON API, which isn't enabled by default. Please check to see if it is enabled in the Google APIs console.

Upvotes: 2

Related Questions