2

The Problem

I'm integrating Stack Exchange API on iOS (iPhone). I've run into a situation where I can't log out and authenticate with a different account. I am stuck with the first account that I have ever authenticated with. This scenario could be useful if a device is shared between multiple people or one person needs to switch from a work account to a personal account.

Steps to Reproduce

1) Embed a web view with this URL:

[NSString stringWithFormat:@"https://stackexchange.com/oauth/dialog?client_id=%@&scope=no_expiry,write_access&redirect_uri=https://stackexchange.com/oauth/login_success", CLIENT_ID];

2) After the user logs in with a Google account, the web view's URL hash is updated with their access token. I save this access token.

self.accessToken = {regex parsing of the URL};

3) The user decides he wants to log out. I invalidate the access token and erase my client side storage of it. The response from the Stack Exchange server seems fine.

- (void)logOut
{
    [[HttpHelper alloc] requestWithUrl:[NSURL URLWithString:[NSString stringWithFormat:
        @"%@access-tokens/%@/invalidate?key=%@",
        API_BASE_URL,
        self.accessToken,
        APP_KEY
    ]]];
    
    self.accessToken = nil;
}

4) The user now wants to sign in with a different account. He repeats step 1. However, when the web view opens, it immediately logs into Google again. The Stack Exchange OAuth page must have remembered that Google was previously logged in and tries to save the user time by automatically logging him in again without giving the choice of switching to a different account.

0

You must log in to answer this question.

Browse other questions tagged .