Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Fetch Profile Picture From Google Plus

    • 0
    • 2
    • 2
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.50k
    Comment on it

    Hello Readers,

    After the successful authentication from google plus , the following code snippet is one of the ways that can be used to get the url of the profile image:

    - (void)finishedWithAuth: (GTMOAuth2Authentication *)auth
                       error: (NSError *) error {
        [spinner show:YES];
        NSLog(@"Received error %@ and auth object %@",error, auth);
        GTLServicePlus* plusService = [[GTLServicePlus alloc] init ];
        plusService.retryEnabled = YES;
        [plusService setAuthorizer:auth];
    

    // The special value "me" indicates the currently signed in user, but you could use any other valid user ID. Returns a GTLPlusPerson.

    GTLQueryPlus *query = [GTLQueryPlus queryForPeopleGetWithUserId:@"me"]; 
        [plusService executeQuery:query
                completionHandler:^(GTLServiceTicket *ticket,
                                    GTLPlusPerson *person,
                                    NSError *error) {
    

    //person here contains the basic information of the user currently logged in

                    if (error) {
                        GTMLoggerError(@"Error: %@", error);
                    } else {
                        NSString *imageUrl = person.image.url; // This is the url of the profile image
                        NSString *emailID=[auth.parameters objectForKeyWithNullCheck:@"email"];
                        NSString *name=person.displayName;
                        NSString *idName= [auth.parameters objectForKeyWithNullCheck:@"id_token"];
                       }
                  }];
    }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: