2014-04-25 61 views
0

我使用谷歌雲上傳(https://developers.google.com/storage/docs/json_api/v1/how-tos/upload)API上傳圖像從IOS。谷歌雲存儲JSON上傳API顯示錯誤

我有以下code.For REST經理我使用從這裏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); 
    }]; 
} 

我收到下面從谷歌雲存儲API錯誤消息的代碼。我已按照所有說明在Google開發者控制檯中配置應用。

{ 
"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." 
} 

任何人都可以幫助我嗎?

+0

夫婦簡單的問題。首先,你如何認證?其次,在控制檯上,在APIs&auth => APIs下,將「Google Cloud Storage JSON API」設置爲ON或OFF? –

+0

我正在使用API​​密鑰和oauth2.0兩者。那是在 –

回答

1

我假設你使用的是iOS密鑰。對於這個特定的用例,這實際上並不正確。我知道爲iOS應用使用iOS密鑰似乎顯然是正確的,但奇怪的是它不是。

這裏有一個偉大的回答,說明要做什麼:Getting status "REQUEST_DENIED" after fetching data from google places API

+0

是我的項目有相同的捆綁ID。 –

+0

你使用它得到了正確的答案嗎?我不知道它看起來完全有線! –

+0

啊,對不起,我很困惑。我修改了我的答案。 –