How to Sign Out of Google After Being Authenticated

后端 未结 6 968
伪装坚强ぢ
伪装坚强ぢ 2021-02-06 23:54

So my app has the option to sign in with Google. Upon clicking the button that Google provides, a web view opens and has the user input their credentials. After allowing the app

6条回答
  •  鱼传尺愫
    2021-02-07 00:01

    if anyone is still looking at this i think i have this working a the OP originally asked.

    So in my case i did something like this:

    GIDSignIn *gidObject = [GIDSignIn sharedInstance];
    [gidObject signOut];
    [gidObject disconnect];
    
    
    NSString *logOutUrl = @"https://www.google.com/accounts/Logout";
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString: logOutUrl] options:@{} completionHandler:nil];
    

    I had the application go to the google logout url as seen above. For our workflow i wanted the user to actively know they are logging out. Kinda like a check for the user. What i had wrong is the signOut and disconnect of GIDSignIn. Before I had the signOut proceed after disconnect. When I had it that way no matter what the user did they were never "signed out" of google. When I reversed disconnect and signOut it logs the user out of their google account, which is what we wanted.

    I guess logically one would signOut first before disconnecting from the app.

提交回复
热议问题