ここで入手できるObjectiveC用のGoogleCLientライブラリを使用しています。ユーザーを認証して更新トークンを取得することができました。(組み込みのGTMOAuthenticaion APIを使用)。
承認が成功した後に呼び出されるセレクターで、次のようにユーザープロファイルの取得要求を行います。(現在ログイン/認証されているユーザーのIDが必要です)
-(void)viewController:(GTMOAuth2ViewControllerTouch *)viewController
finishedWithAuth:(GTMOAuth2Authentication *)auth
error:(NSError *)error {
if (error != nil) {
NSLog(@"Stop");
} else {
if ([auth canAuthorize]){
[Mediator plusService].authorizer = auth;
// Problematic Line
GTLQueryPlus *profileQuery = [GTLQueryPlus queryForPeopleGetWithUserId:@"me"]; // Notice the UserId Param
profileQuery.completionBlock = ^(GTLServiceTicket *ticket, id object, NSError *error) {
if (error == nil) {
self.mediator.gProfile = object;
} else {
NSLog(@"GPlus Service Error %@", error);
}
};
[[Mediator plusService] executeQuery:profileQuery completionHandler:
^(GTLServiceTicket *ticket, id result, NSError *error) {
if (error)
NSLog(@"Some Service Error %@", error);
}];
}
}
}
パラメータとして「me」を入力すると、jSON応答で無効なユーザーIDエラー文字列が表示されます。
ただし、自分の113632923069489732066のようなuserIdを指定すると、完全に正常に機能し、適切なjSON応答が返されます。
Examplesフォルダ内のExampleforGoogle Plusも、現在のユーザープロファイルを取得できず、次のエラーで終了します。
Error Domain=com.google.GTLJSONRPCErrorDomain Code=400 "The operation couldn’t be completed. (Invalid user ID: {0})" UserInfo=0x7a670fa0 {NSLocalizedFailureReason=(Invalid user ID: {0}), GTLStructuredError=GTLErrorObject 0x7a67b130: {message:"Invalid user ID: {0}" code:400 data:[2]}, error=Invalid user ID: {0}}
PS My API Consoleアプリケーションは、インストールされているアプリのiOSオプションでは機能しませんが、[その他]オプションで構成する必要があります。iOSオプションで構成されている場合、oAuthはinvalid_clientエラー応答で失敗します。