0

Before you guys jump at me that 403 means there's something wrong with my consumer key... fine. But what? I triple checked the bundle identifier matches in my app and on the api key and google custom search is enabled. If I try to user another key like a web key or no key at all I get error 400. Apparently my reputation is too low to post images so you will have to trust me on what the error looks like and that custom search is enabled on the api key and that image search is switched on for the custom search engine and the "search entire web but emphasize included sites" option is enabled.

CODE:

[DZNPhotoPickerController registerService:DZNPhotoPickerControllerServiceGoogleImages consumerKey:@"A*****************************" consumerSecret:@"00***************************" subscription:DZNPhotoPickerControllerSubscriptionFree];

DZNPhotoPickerController *picker = [[DZNPhotoPickerController alloc] init];
picker.supportedServices = DZNPhotoPickerControllerServiceGoogleImages;
picker.delegate = self;
picker.enablePhotoDownload = YES;
picker.infiniteScrollingEnabled = YES;
[self presentViewController:picker animated:YES completion:nil];

1 Answers1

0

Have you tried the sample pod with your keys to make sure it works? eg https://github.com/dzenbot/DZNPhotoPickerController Are you even using real keys or are you using the sample keys? Get real keys here : https://developers.google.com/image-search/

This other user found that google rejected his requests if all the fields were not populated. Google Custom Search: 403 error in iOS Maybe you need to set some more of your fields? eg:

// or whatever
imagePicker.mediaTypes = [NSArray arrayWithObjects:(NSString *)kUTTypeImage, nil];

Of course the google image search API is deprecated (The Google Image Search API has been officially deprecated as of May 26, 2011.). Others seem to be able to use it... maybe your keys are reversed? eg secret key in consumer and vice versa.

Where are you getting the 403? Which method? Maybe you should use wireshark to ensure your request is properly populated. I assume if you snag the URL, you've tried it from a normal browser outside of iOS to ensure it works first?

Community
  • 1
  • 1
LawfulEvil
  • 2,267
  • 24
  • 46
  • I'm using real keys. I can't test it from a browser because i'm trying to not use the browser key but the iOS key which requires the request be made from a project with the correct bundle identifier. I think perhaps the pod is incorrectly configured to use a browser key. Their example works with a browser key I created but not with the iOS key, even if I include the sample project bundle identifier in the list of projects allowed to use that particular key. – krazeeKoder Apr 08 '16 at 19:39
  • however when I test the web browser key with my own code I get "request failed: bad request (400)" – krazeeKoder Apr 08 '16 at 19:44