accessNotConfigured:iOS模拟器上的Google URL缩短API

vin*_*nay 5 objective-c google-api ios google-url-shortener ios8

我已将Google URL-Shorten API我的iOS应用程序集成到测试目的中.我的应用程序的Bundle ID由我添加Authorized iOS Applications到发送请求的列表中.

但每当我发送HTTP POST请求时NSURLRequest,我都会收到以下错误JSON:

{
 "error": {
  "errors": [
   {
    "domain": "usageLimits",
    "reason": "accessNotConfigured",
    "message": "Access Not Configured. The API is not enabled for your project, or 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 configuration.",
    "extendedHelp": "https://console.developers.google.com"
   }
  ],
  "code": 403,
  "message": "Access Not Configured. The API is not enabled for your project, or 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 configuration."
 }
}
Run Code Online (Sandbox Code Playgroud)

我无法弄清楚如何解决这个问题.我猜的一个"可能是我必须在在线应用程序上使用API​​"

支持参考我的猜测来自API文档

If your application accesses APIs directly from iOS, you will need the application's Bundle ID and (optionally) its Apple App Store ID:

The application's Bundle ID is the bundle identifier as listed in the app's .plist file. For example: com.example.myapp.
The application's App Store ID is in the app's iTunes URL so long as the app was published in the Apple iTunes App Store. For example, in the app URL http://itunes.apple.com/us/app/google+/id447119634, the App Store ID is 447119634.
Run Code Online (Sandbox Code Playgroud)

DaI*_*mTo 1

由于错误表明您没有正确配置对 API 的访问,或者您没有对应用程序进行身份验证。

授权请求并识别您的应用程序

您的应用程序发送到 Google URL Shortener API 的每个请求都需要向 Google 识别您的应用程序。有两种方法可以识别您的应用程序:使用 OAuth 2.0 令牌(也授权请求)和/或使用应用程序的 API 密钥。以下是确定使用哪些选项的方法:

您需要在Google Developer 控制台中设置项目,启用URL Shorter API,并使用 API 密钥或 Oauth2 来访问它。