我有一些用户的谷歌iD,我想在我的应用程序中显示他的谷歌个人资料照片。在我的swift
代码中,我尝试使用必要的信息(基于此答案https://stackoverflow.com/a/22526130/3766930)获取json。这是我的代码:
Alamofire.request(.GET, "https://www.googleapis.com/plus/v1/people/10263...4252?key=AI...Oo")
.responseJSON { response in
print(response)
switch response.result {
case .Success:
dispatch_async(dispatch_get_main_queue(),{
if let jsonData = response.result.value as? [[String: AnyObject]] {
print(jsonData)
}
})
case .Failure(let error):
print("SWITCH ERROR")
print(error)
}
}
但作为回应我收到了这个错误:
error = {
code = 403;
errors = (
{
domain = usageLimits;
extendedHelp = "https://console.developers.google.com";
message = "There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed.";
reason = ipRefererBlocked;
}
);
message = "There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed.";
};
我仔细浏览了我的谷歌开发者控制台,但我没有设置任何IP限制。这是它到目前为止的样子:
我正在使用这里的api密钥:
正如您所看到的,这里没有域名限制:
这个奇怪的错误可能是什么原因?
答案 0 :(得分:4)
在Google Developers Console中删除API密钥的iOS捆绑包标识符限制。捆绑标识符限制仅在您使用file serving servlet时才有效。