0

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.

spirie
  • 21
  • 5
  • The API does require authorization to mount the folder in the receiving account, so there isn't a way to fully automate that. Your solution for logging out the user does work (although it's not documented as part of the API, and so isn't officially supported), but alternatively you can use the `force_reapprove` parameter on [/oauth2/authorize](https://www.dropbox.com/developers/documentation/http/documentation#authorization) to at least give the user the opportunity to log out themselves. – Greg Oct 11 '16 at 16:22
  • Thanks @Greg, will also give that a go – spirie Oct 12 '16 at 09:48

1 Answers1

0

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)));
spirie
  • 21
  • 5