1

ユーザーのサークル内のユーザーを取得しようとしています。 GPPSigninは控除されているので、私はログインにGIDSignInを使用しています。 GIDSignInによって提供される認証はGTLServicePlusで使用できないタイプのGIDAuthenticationですGoogle+サークルのユーザーを呼び出すiOS

私はGIDSignInButtonを使用して正常にサインインしました。ここでは、人々を取得するために私のコードは、だから私は現在、手動GTMOAuth2Authenticationオブジェクトを作成し、それに必要な値を割り当てることによってこの問題を解決しています

GTLServicePlus* plusService = [[[GTLServicePlus alloc] init] autorelease]; 
plusService.retryEnabled = YES; 

[plusService setAuthorizer:[GPPSignIn sharedInstance].authentication]; //Problem is here 
GTLQueryPlus *query = 
[GTLQueryPlus queryForPeopleListWithUserId:@"me" 
           collection:kGTLPlusCollectionVisible]; 
[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]; 
     } 
    }]; 
+0

この問題は解決しましたか? –

+0

@AlexanderVolkov私は現在、GTMOAuth2Authenticationオブジェクトを手動で作成し、必要なすべてのフィールド(clientID、userEmail、userID、accessToken、refreshToken、expirationDate)を割り当てています。それは当分の間働いています。 –

+0

したがって、Goolge Plus SDKとGoogle Sign-Inの両方のフレームワークを使用していますが、正しいですか?あなたは例を挙げていただけますか? Google Plus Web APIを使用しようとしましたか? –

答えて

0

をリストしています。これは私の現在のコードです。

func fetchGPlusContacts() { 

    let plusService = GTLServicePlus() 
    plusService.retryEnabled = true 

    let user = signIn.currentUser 
    let auth = GTMOAuth2Authentication() 

    auth.clientID = signIn.clientID 
    auth.userEmail = user.profile.email 
    auth.userID = user.userID 
    auth.accessToken = user.authentication.accessToken 
    auth.refreshToken = user.authentication.refreshToken 
    auth.expirationDate = user.authentication.accessTokenExpirationDate 

    plusService.authorizer = auth 

    let query = GTLQueryPlus.queryForPeopleListWithUserId("me", collection: kGTLPlusCollectionConnected) as! GTLQueryPlus 


    plusService.executeQuery(query) { (ticket, peopleFeed, error) in 
     if (error != nil) { 
      print("error: \(error.description)") 

      if (self.delegate != nil) { 
       if self.delegate?.failedFetchFriendsFromGoogle != nil { 
        self.delegate!.failedFetchFriendsFromGoogle!(error) 
       } 
      } 
     } 
     else { 
      if let peopleFd = peopleFeed as? GTLPlusPeopleFeed { 
       var items : [GTLPlusPerson] = [] 
       if let itms = peopleFd.items() as? [GTLPlusPerson] { 
        items = itms 
       } 
      } 
     } 
    } 
} 

私はまだこのタスクを実行する正しい方法を探しています。

関連する問題