0

I am using Google Plus integration where I have to fetch circles of user.

I am passing the Url:https://www.googleapis.com/plus/v1/people/Your_User_Id/people/visible?key=APP_Key.

I am getting the response as:

{ error = { code = 403; errors = ( { domain = global; message = Forbidden; reason = forbidden; } ); message = Forbidden; }; }

What kind of permission do I need for This request?

Midhun MP
  • 103,496
  • 31
  • 153
  • 200
Imran Naseem
  • 17
  • 1
  • 9
  • i think you must see this link for your question http://stackoverflow.com/questions/10820536/get-google-user-friends – iKambad Jul 10 '13 at 06:28
  • Thanks for the response.It is one year old post.May be they have allowed now since it is written in docs that they allow fetching circles using the url I used above but getting forbidden response like above. – Imran Naseem Jul 10 '13 at 08:59

1 Answers1

5

You can only do this for the signed in user - so the "Your_User_Id" should always be "me". It's fine to pass the app key as well, but you must be making the call with an oAuth 2.0 token from a user who has signed in to your app. You can see all the details here: https://developers.google.com/+/mobile/ios/people#retrieve_a_collection_of_people

Basically you'd need to implement sign-in, if you haven't already, then you can use the plusService in the GPPSignIn sharedInstance:

GTLQueryPlus *query =
    [GTLQueryPlus queryForPeopleListWithUserId:@"me"
                                    collection:kGTLPlusCollectionVisible];
[[[GPPSignIn sharedInstance] plusService] executeQuery:query
        completionHandler:^(GTLServiceTicket *ticket,
                            GTLPlusPeopleFeed *peopleFeed,
                            NSError *error) {
            if (error) {
              GTMLoggerError(@"Error: %@", error);
            } else {
              // Get an array of people from GTLPlusPeopleFeed
              NSArray* peopleList = [peopleFeed.items retain];
            }
        }];

That is calling the URL that you're giving there.

Ian Barber
  • 19,765
  • 3
  • 58
  • 58
  • Thanks a lot for your response.This is the exact answer along with what I was missing is the scopes permission.[NSArray arrayWithObjects: @"https://www.googleapis.com/auth/plus.moments.write", @"https://www.googleapis.com/auth/plus.me",@"https://www.googleapis.com/auth/plus.login",@"https://www.googleapis.com/auth/plus.me",@"https://www.googleapis.com/auth/userinfo.email", nil] :...This solved my problem. – Imran Naseem Jul 11 '13 at 07:01
  • One more thing Ian,Does google+ API allow to send messages to friends in circle or some kind of invitation to friends or any means of communication in the circle.I read the API but do not get any clue regarding this. – Imran Naseem Jul 11 '13 at 07:47
  • 1
    You can't send one automatically (e.g. via an API call), but you can use the share functionality, and pre-fill some text for the user: https://developers.google.com/+/mobile/ios/share – Ian Barber Jul 11 '13 at 18:28
  • But that one is being shared in the circle itself.Not as a private message to a friend.Am I right? – Imran Naseem Jul 30 '13 at 06:09
  • You can share to a singe person, which is the closest equivalent to a private message. – Ian Barber Aug 02 '13 at 10:35
  • Exact solution. But unable to get Email Ids of the people. Please can you explain how can we get email of the people. Thanks in advance. – Jagdev Sendhav May 26 '14 at 09:42