GIDSignIn Error Code 401

201 views Asked by At

I was trying to implement google signin and to fetch the profile detail along with contact list by giving following scope

    NSString *driveScope = @"https://www.googleapis.com/auth/plus.login";
    NSString *driveScope2 = @"https://www.googleapis.com/auth/plus.me";
    NSArray *currentScopes = [GIDSignIn sharedInstance].scopes;   
    [GIDSignIn sharedInstance].scopes = [currentScopes arrayByAddingObject:driveScope];
    [GIDSignIn sharedInstance].scopes = [currentScopes arrayByAddingObject:driveScope2];    
    [[GIDSignIn sharedInstance] signIn];

After authentication, user info has been fetched but to get user contacts, using following API:

-(void) fetchUserContacts
{
    self.url = [NSString stringWithFormat:@"https://www.googleapis.com/plus/v1/people/me/people/visible?access_token=%@",GIDSignIn.sharedInstance.currentUser.authentication.accessToken];
    HttpRequest *request = [[HttpRequest alloc] init];
    request.delegate = self;
    [request makeRequestWithURL:self.url andHttpKey:@"Contacts"];
}

but the response is:

**error =     {
    code = 401;
    errors =         (
                    {
            domain = global;
            location = Authorization;
            locationType = header;
            message = "Invalid Credentials";
            reason = authError;
        }
    );
    message = "Invalid Credentials";

}**

Please help me to resolve this issue. Thanks in advance.

0

There are 0 answers