Dropbox library (LC 9) - does dropboxGetCurrentAccount work?

Ben Rubinstein benr_mc at cogapp.com
Wed Oct 11 06:23:58 EDT 2017


Hi Mike (or anyone else)

Can you confirm that dropboxGetCurrentAccount (NOT dropboxGetAccount) is 
working for you in LC 9.0.0 dp 9?

It consistently fails for me, and the problem seems to be precisely the lack 
of a parameter other than the access token.

Dropbox returns a 400, AFAICT, precisely because the POST is empty. Fiddling 
with this in curl, I find that

$ curl -X POST https://api.dropboxapi.com/2/users/get_current_account \
    --header "Authorization: Bearer <Access Token>"

works and returns the expected data; but

$ curl -X POST https://api.dropboxapi.com/2/users/get_current_account \
    --header "Content-Type: application/json" \
    --header "Authorization: Bearer <Access Token>" \
    --data-ascii ""

which is roughly what LC is doing, fails with 400 Bad Request.

In other words, it seems that Dropbox requires this call to be made as a POST 
with no data at all; and that what LiveCode does when posting empty to a URL 
is a post with a content-length of 0 - and Dropbox won't accept it.

So I'm puzzled as to how this is working for you. Are you using a different 
version of DP9 with a different tsNet version perhaps?

TIA,

Ben

On 11/10/2017 08:05, Ben Rubinstein via use-livecode wrote:
> Hi Mike,
> 
> Thanks for checking. According to the Dictionary, dropboxGetCurrentAccount 
> only takes one parameter
>      dropboxGetCurrentAccount pAccessToken, [pCallback]
> 
> if it's supposed to take two, that would explain the 400 error! But how does 
> one obtain the account_id in the first place?
> 
> I'm really only wanting to make this call because it looked liked the cheapest 
> way to find out if the app has a valid token for Dropobox; I can either 
> display the account it's logged in to, or a button offering to log in. Is 
> there another way?
> 
> Many thanks,
> 
> Ben
> 
> On 11/10/2017 01:49, Mike Kerner via use-livecode wrote:
>> It works for me in both 8 and 9.
>> The only way I get error 400 is if I enclose the arguments in parenthesis
>> (which tells LC that all of that goodness goes into the first parameter)
>> Remember, this is a command, not a function, so the arguments are not
>> enclosed:
>>
>> dropboxGetCurrentAccount oauthToken, account_id
>> if the result is not empty then
>> answer the result
>> exit to top
>> else #the result is empty
>> answer it
>> end if #the result is not empty
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription 
>> preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
> 




More information about the Use-livecode mailing list