Dropbox app destined to interact with only one dropbox account

后端 未结 2 1549
梦毁少年i
梦毁少年i 2021-02-06 17:17

My need is to have a simple web form that also lets people upload some pdf\'s. What I was thinking I could do (because of the size and number of uploaded files) is to tie the ba

2条回答
  •  执笔经年
    2021-02-06 17:50

    I have had a similar issue using Facebook (FB) API in a few cases - where what I wanted was to have my server talk to FB in order to sync with my account - but the API is generally intended for use with the account of the person accessing the site.

    The problem is that if you try to connect client-side, as the API is generally intended, you need to expose your own private log-in / credentialization via a client-side script... which clearly isn't good.

    The trick I've used is to wrap the API server-side with a series of methods which allow you to perform the specific functions you need, then allow your JS or server-side binding to call those methods async. The resulting flowchart looks something like:

    ------            ----------                               -------
    | UI | -> AJAX -> | Server | -> Async GET w/Credentials -> | API |
    ------            ----------                               -------
    

    You then get the data back at the Server level and return it to the UI as JSON - and voila, your UI has no credentials - but still has access to your DropBox.

    So - for your example of uploading a file... The user is going to post a file to your web-server. On the Server-side handler for the method - simply take the posted binary information, form it into a new API call to your drop-box - authenticate (if you don't already have an active authenticated session) - and then post. You can then return information to your client-side based on the success / failure of that call.

    I hope this helps. :) Takes a bit of scaffolding - but it is possible! Have faith!

提交回复
热议问题