AccessNotConfigured: Google URL URL for iOS API

I integrated the Google URL-Shorten API in my iOS application for testing purposes only. The Bundle ID of my application is added by me to the Authorized iOS Applications list to send a request.

But whenever I send an HTTP POST request using NSURLRequest , I get the following error in the JSON response:

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

I can’t figure out how to solve this. I assume that "maybe I need to use the API in an online application"

By maintaining a link to my guess from the API documentation

 If your application accesses APIs directly from iOS, you will need the application Bundle ID and (optionally) its Apple App Store ID: The application Bundle ID is the bundle identifier as listed in the app .plist file. For example: com.example.myapp. The application App Store ID is in the app 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. 
+5
source share
3 answers

When configuring the API key, DO NOT provide an optional iOS package identifier if you are not using OAuth 2.0. Google API Keys for Using iOS

I ran into the same error, deleted the packet identifier and cleared 403 while still using the API key in the HTTP request with NSURLSession.

You can remove this error by accessing the Google Developer Console by clicking "Credentials" in the APIs and auth, and then clicking on the API key name. You will then get a screen where you can remove the iOS package identifier associated with the API key. Then click the "Save" button and retest.

+3
source

As stated in the error, you incorrectly configured access to the API or do not authenticate the application.

Request authorization and definition of your application

Each request that your application sends to the Short Google APIs needs to identify your application with Google. There are two ways to identify your application: using the OAuth 2.0 token (which also allows the request) and / or using the application API key. Here's how to determine which of these options to use:

You need to set up the project in the Google Developer Console to the URL Shorter API and use either the API key to access it or Oauth2.

+1
source

You may have missed the API key transfer. You could see how to pass the key here .

0
source

Source: https://habr.com/ru/post/1209527/


All Articles