cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Are you interested in hearing how one of our Community members uses Dropbox for sailing trips? Read all about it here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Logged out from dropbox and login again. It is allowing me to access files without asking credential

Logged out from dropbox and login again. It is allowing me to access files without asking credential

vinay05
Explorer | Level 3

I am using ObjectiveDropboxOfficial for my ios objective c project.

 

Everything is working fine except logout.

Here is the problem,

 Step 1: Logged into dropbox.

Step 2: Logged out from dropbox.

Step 3: Trying to login again. It should ask me for login credentials because, i already logged out from dropbox which is not happening. Instead, it directly takes me to after login process screen. I attached the screenshot for that screen below.

https://drive.google.com/file/d/14887FaYrUoZZ5fwzbDXSHa0LHEWggqhn/view?usp=sharing


I tried all the possibilities that were given in the sdk, nothing helps.

 

Here is the code to logout from dropbox

    [[ODBoxHandler sharedHandler] clientRequestedLogout];

 

Cleared cache from browser

    [[NSURLCache sharedURLCache] removeAllCachedResponses];

 NSHTTPCookieStorage *cookieJar = [NSHTTPCookieStorage sharedHTTPCookieStorage];

            for(NSHTTPCookie *cookie in [cookieJar cookies]) {

                    NSLog(@"Cookies attached: %@", cookie.description);

                if(cookie){

                    [cookieJar deleteCookie:cookie];

                }

            }

 

Cleared saved access token from keychain and dropbox.

    [DBSDKKeychain clearAllTokens];

    [DBClientsManager unlinkAndResetClients];

 

 

Dropbox sdk internally uses SFSafariViewController, where the cache is not cleared until i close the app and reopen again.

 

Any suggestions would be greatly helpful.

 

 

1 Reply 1

Greg-DB
Dropbox Staff

As you mentioned, when processing the OAuth app authorization flow in an app using ObjectiveDropboxOfficial, SFSafariViewController is used. The web session in SFSafariViewController (such as whether the user is already signed in to www.dropbox.com) is separate from whether or not the ObjectiveDropboxOfficial SDK has any locally stored access/refresh tokens. The clearAllTokens and unlinkAndResetClients methods only affect the locally stored access/refresh tokens, not the web session, so calling those won't sign the user out of the Dropbox web site.

 

Also, ODBoxHandler isn't made by Dropbox so I can't help with that, but if you're referring to this third party library, it looks like that clientRequestedLogout method just calls unlinkAndResetClients too.

 

Likewise, while I can't provide support for NSURLCache as that's not made by Dropbox, it sounds like it's not possible to clear the SFSafariViewController session using NSURLCache. For instance, I found this post that indicates it's not possible to interact with or clear SFSafariViewController credentials.

 

So, it looks like it's not possible to proactively clear out the entire SFSafariViewController session directly. You could clear the cookies for www.dropbox.com in SFSafariViewController however by presenting a SFSafariViewController for the URL "https://www.dropbox.com/logout", though that's not part of the API/SDK, so ObjectiveDropboxOfficial doesn't offer a method for that. Doing so from your own code should work, though it would involve showing the SFSafariViewController UI again.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?