Google Custom Search is returning this 403 error from my iPhone 7.1 app. This is the response when run in the simulator:
{
"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."
}
}
Is there a flaw in the steps below? I’d like to establish a working CSE setup process specific to iOS apps. The screenshots at each step will hopefully help and not confuse!
Create a Custom Search Engine (CSE) at https://www.google.com/cse/
From Setup -> Basics, get the Search engine ID.
Test the CSE at https://developers.google.com/apis-explorer/#p/customsearch/v1/search.cse.list
To get ourselves a key for ID and billing purposes, create a new project at https://console.developers.google.com/
Under APIs & auth -> APIs -> Enable "Custom Search API." No other APIs are enabled.
Under APIs & auth -> Credentials -> Create a new iOS key.
Note: I also tried a browser key and the search result returned "Error 400: Invalid Value." I returned to the iOS key since I'm on iOS and the error seemed less severe.
Add to this key your bundle identifier from Xcode.
In Xcode make your GET request to the URL in step 3. Replace {YOUR_API_KEY} with the key from your credentials in steps 6-7.
NSData *response contains the error 403 shown above. Thanks for any thoughts on what's wrong!
It was missing the header field X-Ios-Bundle-Identifier.
NSString *bundleID = @"com.yourCompany.yourApp";
//...define request as above
[request setHTTPMethod:@"GET"];
[request setValue:bundleID forHTTPHeaderField:@"X-Ios-Bundle-Identifier"];