phpdropbox-apidropbox-php

Auto-Mount Folder / Force Logout for second oAuth2 flow


I am programmatically creating a folder structure in one account (that has been oAuth2 authenticated) and then sharing the folder. Works great.

Then I am adding a member to the folder so they can edit files within it. The problem I have is that it doesnt automatically appear in the end users Dropbox folders - they have to go in and add/mount it. That's fine, as I can do mount_folder via the API, but a bit of a pain because I'm not logged in to the user account (and we want the whole thing to be seamless, without user interaction).

Our system can prompt again for the oauth2 flow for the "user" account, but the problem is that we will likely already be logged in to the "main" account from the original oauth2 flow - so simply returns back & doesnt ask for a new login.

Is there a way to "force logout" whilst doing the oAuth2 flow for the second time?

Or, is there a way to simply have dropbox auto-mount the folders and not need user interaction to add them?

FYI, we are using PHP.


Solution

  • The simplest solution was to utilise the redirect parameter in Dropbox to logout the user (if need be) first and then redirect to the auth url again. Not perfect, but it works.

    Have changed the second oAuth2 url to:

    header("Location: https://www.dropbox.com/logout?cont=".urlencode(filter_var($auth_url, FILTER_SANITIZE_URL)));