Connect to DropBox with Oauth2

Hello,

I’m currently trying to connect to Dropbox with the forge provider module. I tried following manifest definition :

auth:
    - key: dropbox
      name: Dropbox
      scopes:
        - 'account_info.read'
        - 'files.metadata.write'
        - 'files.content.write'
        - 'files.content.read'
        - 'profile'
        - 'openid'
        - 'email'
      type: oauth2
      clientId: <clientId>
      remotes:
        - dropbox-account
      bearerMethod: authorization-header
      actions:
        authorization:
          remote: dropbox-account
          path: /oauth2/authorize
          queryParameters: 
            response_type: "token"
        exchange:
          remote: dropbox-oauth
          path: /oauth2/token
        retrieveProfile:
          remote: dropbox-oauth
          path: /2/openid/userinfo
          resolvers:
            id: sub
            displayName: email

and as remotes I defined:

 remotes:
  - key: dropbox-account
    baseUrl: https://www.dropbox.com
  - key: dropbox-oauth
    baseUrl: https://api.dropboxapi.com

The problem is that the endpoint “/2/openid/userinfo” use a post method and I’m getting following error

could not retrieve profile information: Error in call to API function "openid/userinfo": Use HTTP POST requests instead of GET to access Dropbox API's

Does anyone know how to configure the http method or connect to Dropbox in another way?

Kind regards,
Richard

Hi @RichardAdler, we are working on supporting different methods for the profile retriever endpoint on our side, it might be a couple of weeks away though. Are there any alternative profile endpoints which you can use? If you are trying to connect to personal accounts (not business accounts) you should be able to use https://www.dropbox.com/developers/documentation/http/documentation#users-get_current_account.

1 Like

Hi @BoZhang,
sadly not. When I use the endpoint, I’m just getting following error:

could not retrieve profile information: <!DOCTYPE html> <html> <head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>Dropbox - 404</title> <link href="https://cfl.dropboxstatic.com/static/metaserver/static/css/error.css" rel="stylesheet" type="text/css"/> <link rel="shortcut icon" href="https://cfl.dropboxstatic.com/static/images/favicon.ico"/> </head> <body> <div class="figure"> <img src="https://assets.dropbox.com/www/en-us/illustrations/spot/look-magnifying-glass.svg" alt="Error: 404"/> </div> <div id="errorbox"> <div class="not-found"> <h1>Error (404)</h1> We can't find the page you're looking for. <div class="not-found--links"> Here are a few links that may be helpful: <ul> <li><a href="https://www.dropbox.com/home?_tk=fof">Home</a></li> <li><a href="https://www.dropbox.com/help?_tk=fof">Help center</a></li> <li><a href="https://www.dropbox.com/login?_tk=fof">Sign in</a></li> <li><a href="https://www.dropbox.com/register?_tk=fof">Get a free account</a></li> <li><a href="https://www.dropbox.com/plus?_tk=fof">Dropbox Plus</a></li> <li><a href="https://www.dropbox.com/business?_tk=fof">Dropbox Business</a></li> </ul> </div> </div> </div> </body> </html>

I think the problem is that also the Endpoint https://www.dropbox.com/developers/documentation/http/documentation#users-get_current_account need a post method.
For some reasons DropBox uses always the post methods for their endpoints.

Ahh, sorry I didn’t check the example, just assumed that get_current_account would be a GET, that’s annoying…

It’s going to take us a week or two to get the changes to support different methods through, when it’s available we’ll update the Forge changelogs.

In the meantime, a hacky way to unblock your development is to redirect the profile retrieval endpoint to be a personal REST endpoint which you own that can respond with some dummy values (could be as simple as a locally running server exposed through a Ngrok tunnel).
Please don’t release your app like this though as the profile retrieval is an important aspect for trust, we use the values from profile retrieval to tell the end user what access your app has via the connected apps page.

2 Likes