Get User information after successful authentication with Oauth2

前端 未结 2 385
暗喜
暗喜 2021-01-25 11:38

In my iPhone app I am using google sign in using Oauth2, I am following this insturction and successfully login in

- (void)viewController:(GTMOAuth         


        
2条回答
  •  孤城傲影
    2021-01-25 12:31

    By default, the GTMOAuth2ViewControllerTouch viewController will fetch the user's email, but not the rest of the user's profile.
    The full profile can be requested from Google's server by setting this property before sign-in:

    GTMOAuth2ViewControllerTouch *viewController; viewController.signIn.shouldFetchGoogleUserProfile = YES;

    The profile will be available after sign-in as

       NSDictionary *profile = viewController.signIn.userProfile;
    

    and to get other information you have to change the scope string and begin fetch again.

    here are some scope urls

    @"https://www.googleapis.com/auth/plus.me"

    @"https://www.googleapis.com/auth/userinfo.email"

    @"https://www.googleapis.com/auth/tasks"

提交回复
热议问题