我正在使用 google cloud uploader ( https://developers.google.com/storage/docs/json_api/v1/how-tos/upload ) API 从 IOS 上传图片。
我有以下代码。对于 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 收到以下错误消息。我已按照所有说明在谷歌开发者控制台中配置应用程序。
{
"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."
}
谁能帮帮我?
最佳答案
我假设您使用的是 iOS key 。对于这个特定的用例,这实际上是不正确的。我知道为 iOS 应用程序使用 iOS key 显然是正确的,但奇怪的是事实并非如此。
这里有一个很好的答案,解释了该怎么做:Getting status "REQUEST_DENIED" after fetching data from google places API
关于ios - 谷歌云存储 JSON uploader api 显示错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23288094/