2

I have a google iD of some user and I want to display his google profile photo in my app. In my swift code I try to fetch the json with necessary information (based on this answer https://stackoverflow.com/a/22526130/3766930 ). This is my code:

 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)
                }

        }

but as a response I'm getting this 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.";
    };

I went carefully through my google developers console and I don't have any IP restrictions set up. This is how it looks so far:

I'm using the api key from here:

enter image description here

enter image description here

as you can see there is no domain limitation here:

enter image description here

What might be the reason of this weird error?

Community
  • 1
  • 1
user3766930
  • 5,629
  • 10
  • 51
  • 104
  • duplicate of http://stackoverflow.com/questions/36209983/how-to-fetch-users-profile-photo-from-google-and-not-from-google. Please ask your question only once. – Jay Lee Mar 25 '16 at 13:21

1 Answers1

5

Remove the iOS bundle identifier restrictions for the API key in Google Developers Console. The bundle identifier restrictions only work when you use the Google client libraries.

Patrick
  • 476
  • 3
  • 3