Login through google plus to native app does not shows login page every time?

笑着哭i 提交于 2019-12-11 09:26:16

问题


in my app have a option for user to login to the app using google +?Here Login page is showing only once for the first time when user taps on google Plus button from next time when i click on google plus button its directly navigation to permissions page instead of going to loginPage

My code is

//////////////CODE FOR LOGIN

GPPSignIn *signIn = [GPPSignIn sharedInstance];
signIn.delegate = self;
signIn.shouldFetchGooglePlusUser = YES;
signIn.shouldFetchGoogleUserEmail = YES;  // Uncomment to get the user's email
signIn.shouldFetchGoogleUserID= YES;
signIn.clientID = kClientId;
signIn.scopes = [NSArray arrayWithObjects:
                 kGTLAuthScopePlusLogin, // defined in GTLPlusConstants.h
                 nil];
signIn.actions = [NSArray arrayWithObjects:@"http://schemas.google.com/ListenActivity",nil];
[signIn authenticate];

/////////////////////////CODE FOR LOGOUT

  - (void)Logout:(id)sender {

     [[GPPSignIn sharedInstance] signOut];
    [self performSelector:@selector(disconnect) withObject:nil afterDelay:1.0f];
   }
   - (void)disconnect {
[[GPPSignIn sharedInstance] disconnect];
  }

回答1:


Once the user has authenticated with you, the GPP library stores a refresh token in the keychain. Next time they come back you can call trySilentAuthentication to check whether they can sign-in automatically.

If you do sign out and call authenticate again, the app wont show them a consent screen if they've already granted consent on that device. In this case, you are trying to disconnect to force it, but because you're doing it after the sign out the tokens have already been removed.

If you want your users to see the sign-in screen each time (though that doesn't sound like a very good experience!) just store a local flag for whether they've done so, and don't call authenticate until that point.



来源:https://stackoverflow.com/questions/19629899/login-through-google-plus-to-native-app-does-not-shows-login-page-every-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!