0

I am using google cloud uploader (https://developers.google.com/storage/docs/json_api/v1/how-tos/upload) API to upload image from IOS.

I have below code.For REST Manager I am using code from here https://github.com/SSamanta/SSRestClient

+(void)uploadData:(NSData *)data withName:(NSString *)name onCompletion:(ServiceCompletionHandler)handler {
    SSRestManager *restManager = [[SSRestManager alloc] init];
    restManager.httpMethod = @"POST";
    restManager.contentType = @"image/jpeg";
    restManager.contentLength = [NSString stringWithFormat:@"%i",data.length];
    restManager.httpBody = data;
    NSString *urlString = [NSString stringWithFormat:@"https://www.googleapis.com/upload/storage/v1beta2/b/videosbetas/o?uploadType=media&name=myObject&key=%@",kAPIKey];
    [restManager getHttpResponseWithBaseUrl:urlString onCompletion:^(id responseData, NSURLResponse *reponse) {
        if (responseData) {
            handler (responseData,nil);
        }
    } onError:^(NSError *error) {
        handler(nil,error);
    }];
}

I am receiving below error message from google cloud storage api. I have followed all the instructions to configure app in google developer console.

{
 "error": {
  "errors": [
   {
    "domain": "usageLimits",
    "reason": "accessNotConfigured",
    "message": "Access Not Configured. Please use Google Developers Console to activate the API for your project."
   }
  ],
  "code": 403,
  "message": "Access Not Configured. Please use Google Developers Console to activate the API for your project."
 }

Can any one help me?

Susim Samanta
  • 1,605
  • 1
  • 14
  • 30

1 Answers1

1

I assume you're using an iOS key. For this particular use case, this is not actually correct. I know using an iOS key for an iOS app seems obviously correct, but oddly it is not.

There's a great answer here that explains what to do: Getting status "REQUEST_DENIED" after fetching data from google places API

Community
  • 1
  • 1
Brandon Yarbrough
  • 37,021
  • 23
  • 116
  • 145
  • Did you get the correct response using that? I don't know it's looking fully wired! – Susim Samanta Apr 27 '14 at 12:42
  • Ah, I'm sorry, I was confused. I have amended my answer. – Brandon Yarbrough Apr 27 '14 at 19:05
  • ok so if I use browser key and HTTP Refer box empty then I am able to get the proper response from google cloud server. is it my correct understandings? – Susim Samanta Apr 28 '14 at 02:07
  • Do you still see "access not configured" errors, or do you see "Login Required" errors? An API key does not authorize your requests in any way, and so I would expect these calls to fail unless you have granted anonymous write permission on your bucket. It's just a way of tagging your requests for quota purposes. – Brandon Yarbrough Apr 28 '14 at 08:08
  • But in doc it's mentioned that we can use API key or Authorization header. So API key is not working in that case.Authorization header I also tried no luck! it's always showing Auth error. I tried with OAuth 2.0 and scopes were correct – Susim Samanta Apr 28 '14 at 10:21
  • Where will I find anonymous write permission of folder? – Susim Samanta Apr 28 '14 at 10:24
  • I found it but no luck still same error.Can you please look into this case? – Susim Samanta Apr 28 '14 at 10:33
  • Yes. You must use either an API key or an authorization header (or a signed URL) when makign requests, but they serve different purposes. Only a proper authorization header grants any privileges to act as a particular user. The API key only grants the right to make a call and does not provide any authorizations at all. Unless you want users to be acting anonymously, you should be using OAuth2 authorization. Also note that you do not need to use an API key if you use an Authorization header. – Brandon Yarbrough Apr 28 '14 at 16:49
  • You shouldn't post your API key here, but I have verified that it works fine for operations that allow anonymous access. `curl "https://www.googleapis.com/storage/v1beta2/b/public-bucket/o?key=YOUR_API_KEY"` shows me a list of objects in a publicly accessible bucket, just as I expected. – Brandon Yarbrough Apr 28 '14 at 16:53
  • How would you get list of objects? I used same link with api key I did not get any response! it's showing me Login required. why it's showing login required? – Susim Samanta May 02 '14 at 09:33
  • @BrandonYarbrough I'm having sort of the same issue as Susim had. I read several places that one should not use the iOS/Android Key. While that's true for several API's, it's not true for Google Cloud Storage. It's stated in the docs that iOS-key is the thing to use. It is sort-of working for me. If I keep the "iOS bundle identifier" blank under the iOS-key, everything is working. But if I change it to my actual bundle identifier, I get code 403 (not configured?). My issue is that gcs isn't recognizing my iOS bundle identifier from my request, apparently. Know anything about this? – Sti May 23 '15 at 16:00