Dropbox library (LC 9) - does dropboxGetCurrentAccount work?

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

Dropbox library (LC 9) - does dropboxGetCurrentAccount work?

J. Landman Gay via use-livecode
New dropbox library great... but when I try to use dropboxGetCurrentAccount, I
consistently get a 400 error code (i.e. Bad Request).

Is this working for anyone else (Mike K??)

TIA,

Ben

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Dropbox library (LC 9) - does dropboxGetCurrentAccount work?

J. Landman Gay via use-livecode
I'll look later.

On Tue, Oct 10, 2017 at 5:17 PM, Ben Rubinstein via use-livecode <
[hidden email]> wrote:

> New dropbox library great... but when I try to use
> dropboxGetCurrentAccount, I consistently get a 400 error code (i.e. Bad
> Request).
>
> Is this working for anyone else (Mike K??)
>
> TIA,
>
> Ben
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



--
On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
   and did a little diving.
And God said, "This is good."
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Dropbox library (LC 9) - does dropboxGetCurrentAccount work?

J. Landman Gay via use-livecode
The thing I tell everyone to do when they want to mess with the new library
is download the original that inspired it, and play with that, because it's
got better documentation and you can mess with everything.  Granted LC's
command names are different, but underneath the code is more-or-less the
same (with some exceptions).

You can download it at my repo
https://github.com/macMikey/dropboxapi_v2

Also, if you want to use LC's library in LC8, you can extract it, or grab
it from my repo for that, too
https://github.com/macMikey/LCDropboxLibrary

On Tue, Oct 10, 2017 at 5:55 PM, Mike Kerner <[hidden email]>
wrote:

> I'll look later.
>
> On Tue, Oct 10, 2017 at 5:17 PM, Ben Rubinstein via use-livecode <
> [hidden email]> wrote:
>
>> New dropbox library great... but when I try to use
>> dropboxGetCurrentAccount, I consistently get a 400 error code (i.e. Bad
>> Request).
>>
>> Is this working for anyone else (Mike K??)
>>
>> TIA,
>>
>> Ben
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>
>
>
> --
> On the first day, God created the heavens and the Earth
> On the second day, God created the oceans.
> On the third day, God put the animals on hold for a few hours,
>    and did a little diving.
> And God said, "This is good."
>



--
On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
   and did a little diving.
And God said, "This is good."
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Dropbox library (LC 9) - does dropboxGetCurrentAccount work?

J. Landman Gay via use-livecode
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
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Dropbox library (LC 9) - does dropboxGetCurrentAccount work?

J. Landman Gay via use-livecode
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
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Dropbox library (LC 9) - does dropboxGetCurrentAccount work?

J. Landman Gay via use-livecode
oh geez, I read your command wrong - you're right - you're using
dropboxGetCurrentAccount, not dropboxGetAccount.

Yes, I'm getting the same error, now.  I'll dive into the code and see if I
can see what's going on.

As far as getting the account_id, for those times when you need it, I would
download the dropboxapi_v2 project (
https://github.com/macMikey/dropboxapi_v2).  Click on the "get started"
checkbox.  There are instructions on how to extract the account_id once you
have the oauth2 token.



On Wed, Oct 11, 2017 at 3:05 AM, Ben Rubinstein via use-livecode <
[hidden email]> 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
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



--
On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
   and did a little diving.
And God said, "This is good."
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Dropbox library (LC 9) - does dropboxGetCurrentAccount work?

J. Landman Gay via use-livecode
In reply to this post by J. Landman Gay via use-livecode
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
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your subscription
>> preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Dropbox library (LC 9) - does dropboxGetCurrentAccount work?

J. Landman Gay via use-livecode
You beat me to it!

On 11/10/2017 11:23, Ben Rubinstein via use-livecode wrote:

> 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
>>> [hidden email]
>>> Please visit this url to subscribe, unsubscribe and manage your
>>> subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your subscription
>> preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Dropbox library (LC 9) - does dropboxGetCurrentAccount work?

J. Landman Gay via use-livecode
In reply to this post by J. Landman Gay via use-livecode
What was working for me was getAccount not getCurrentAccount.  If I use
LC's library with getCurrentAccount, I get the same error.
I have found the bug in LC's library, and I patched it to get it to work,
but I want to understand more of why, and also to make sure I'm not going
to break something else before I issue a pull request.


On Wed, Oct 11, 2017 at 6:23 AM, Ben Rubinstein via use-livecode <
[hidden email]> wrote:

> 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
>>> [hidden email]
>>> Please visit this url to subscribe, unsubscribe and manage your
>>> subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>
>>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



--
On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
   and did a little diving.
And God said, "This is good."
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Dropbox library (LC 9) - does dropboxGetCurrentAccount work?

J. Landman Gay via use-livecode
In reply to this post by J. Landman Gay via use-livecode
Feel like opening a couple QR's?  I think we need two:  one for post and
one for the error in the library.
In fact, there are two problems in the library.  One is the way the library
handles errors returned by dropbox (you only get half the error message),
and the other is the way endpoints like this one are handled.  Hopefully
I'll have both of those patched and up to my repo and the PR submitted,
today.
If you want, you can also patch the library code, but if you do, I'd
suggest moving your project to LC8 and including the patched library stack
as a substack.

On Wed, Oct 11, 2017 at 6:45 AM, Ben Rubinstein via use-livecode <
[hidden email]> wrote:

> You beat me to it!
>
>
> On 11/10/2017 11:23, Ben Rubinstein via use-livecode wrote:
>
>> 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
>>>> [hidden email]
>>>> Please visit this url to subscribe, unsubscribe and manage your
>>>> subscription preferences:
>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>>
>>>>
>>> _______________________________________________
>>> use-livecode mailing list
>>> [hidden email]
>>> Please visit this url to subscribe, unsubscribe and manage your
>>> subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>
>>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



--
On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
   and did a little diving.
And God said, "This is good."
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Dropbox library (LC 9) - does dropboxGetCurrentAccount work?

J. Landman Gay via use-livecode
20555 for POST; 20556 for dropboxGetCurrentAccount.

> I have found the bug in LC's library, and I patched it to get it to work,
> but I want to understand more of why, and also to make sure I'm not going
> to break something else before I issue a pull request.

How are you patching it to work? I can't see any way of issuing a POST request
in LC code (without using curl, which won't work on mobile) that gets round
this problem.

On 11/10/2017 11:58, Mike Kerner via use-livecode wrote:

> Feel like opening a couple QR's?  I think we need two:  one for post and
> one for the error in the library.
> In fact, there are two problems in the library.  One is the way the library
> handles errors returned by dropbox (you only get half the error message),
> and the other is the way endpoints like this one are handled.  Hopefully
> I'll have both of those patched and up to my repo and the PR submitted,
> today.
> If you want, you can also patch the library code, but if you do, I'd
> suggest moving your project to LC8 and including the patched library stack
> as a substack.
>
> On Wed, Oct 11, 2017 at 6:45 AM, Ben Rubinstein via use-livecode <
> [hidden email]> wrote:
>
>> You beat me to it!
>>
>>
>> On 11/10/2017 11:23, Ben Rubinstein via use-livecode wrote:
>>
>>> 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
>>>>> [hidden email]
>>>>> Please visit this url to subscribe, unsubscribe and manage your
>>>>> subscription preferences:
>>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>>>
>>>>>
>>>> _______________________________________________
>>>> use-livecode mailing list
>>>> [hidden email]
>>>> Please visit this url to subscribe, unsubscribe and manage your
>>>> subscription preferences:
>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>>
>>>>
>>> _______________________________________________
>>> use-livecode mailing list
>>> [hidden email]
>>> Please visit this url to subscribe, unsubscribe and manage your
>>> subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>
>
>

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Dropbox library (LC 9) - does dropboxGetCurrentAccount work?

J. Landman Gay via use-livecode
What Gerard did in the original library is use the word "null" instead of
empty.  So his version of __get_current_account_POST would be
private function __get_current_account_POST
return "null"
end get_current_account_POST

For some reason, empty doesn't work, but anything (inluding the word
"null") works.

Before I make the PR I'm going to see if anything else breaks by doing
that, and I'm also going to add the rest of the error message, that gets
dropped.


On Wed, Oct 11, 2017 at 8:27 AM, Ben Rubinstein via use-livecode <
[hidden email]> wrote:

> 20555 for POST; 20556 for dropboxGetCurrentAccount.
>
> I have found the bug in LC's library, and I patched it to get it to work,
>> but I want to understand more of why, and also to make sure I'm not going
>> to break something else before I issue a pull request.
>>
>
> How are you patching it to work? I can't see any way of issuing a POST
> request in LC code (without using curl, which won't work on mobile) that
> gets round this problem.
>
>
> On 11/10/2017 11:58, Mike Kerner via use-livecode wrote:
>
>> Feel like opening a couple QR's?  I think we need two:  one for post and
>> one for the error in the library.
>> In fact, there are two problems in the library.  One is the way the
>> library
>> handles errors returned by dropbox (you only get half the error message),
>> and the other is the way endpoints like this one are handled.  Hopefully
>> I'll have both of those patched and up to my repo and the PR submitted,
>> today.
>> If you want, you can also patch the library code, but if you do, I'd
>> suggest moving your project to LC8 and including the patched library stack
>> as a substack.
>>
>> On Wed, Oct 11, 2017 at 6:45 AM, Ben Rubinstein via use-livecode <
>> [hidden email]> wrote:
>>
>> You beat me to it!
>>>
>>>
>>> On 11/10/2017 11:23, Ben Rubinstein via use-livecode wrote:
>>>
>>> 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
>>>>>> [hidden email]
>>>>>> Please visit this url to subscribe, unsubscribe and manage your
>>>>>> subscription preferences:
>>>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>> use-livecode mailing list
>>>>> [hidden email]
>>>>> Please visit this url to subscribe, unsubscribe and manage your
>>>>> subscription preferences:
>>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>>>
>>>>>
>>>>> _______________________________________________
>>>> use-livecode mailing list
>>>> [hidden email]
>>>> Please visit this url to subscribe, unsubscribe and manage your
>>>> subscription preferences:
>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>>
>>>>
>>> _______________________________________________
>>> use-livecode mailing list
>>> [hidden email]
>>> Please visit this url to subscribe, unsubscribe and manage your
>>> subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>
>>>
>>
>>
>>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



--
On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
   and did a little diving.
And God said, "This is good."
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Dropbox library (LC 9) - does dropboxGetCurrentAccount work?

J. Landman Gay via use-livecode
And, curiously, as it turns out, the other endpoints that take a null post
accept empty (and don't like getting "null").  It seems this only affects
getCurrentAccount.

On Wed, Oct 11, 2017 at 8:52 AM, Mike Kerner <[hidden email]>
wrote:

> What Gerard did in the original library is use the word "null" instead of
> empty.  So his version of __get_current_account_POST would be
> private function __get_current_account_POST
> return "null"
> end get_current_account_POST
>
> For some reason, empty doesn't work, but anything (inluding the word
> "null") works.
>
> Before I make the PR I'm going to see if anything else breaks by doing
> that, and I'm also going to add the rest of the error message, that gets
> dropped.
>
>
> On Wed, Oct 11, 2017 at 8:27 AM, Ben Rubinstein via use-livecode <
> [hidden email]> wrote:
>
>> 20555 for POST; 20556 for dropboxGetCurrentAccount.
>>
>> I have found the bug in LC's library, and I patched it to get it to work,
>>> but I want to understand more of why, and also to make sure I'm not going
>>> to break something else before I issue a pull request.
>>>
>>
>> How are you patching it to work? I can't see any way of issuing a POST
>> request in LC code (without using curl, which won't work on mobile) that
>> gets round this problem.
>>
>>
>> On 11/10/2017 11:58, Mike Kerner via use-livecode wrote:
>>
>>> Feel like opening a couple QR's?  I think we need two:  one for post and
>>> one for the error in the library.
>>> In fact, there are two problems in the library.  One is the way the
>>> library
>>> handles errors returned by dropbox (you only get half the error message),
>>> and the other is the way endpoints like this one are handled.  Hopefully
>>> I'll have both of those patched and up to my repo and the PR submitted,
>>> today.
>>> If you want, you can also patch the library code, but if you do, I'd
>>> suggest moving your project to LC8 and including the patched library
>>> stack
>>> as a substack.
>>>
>>> On Wed, Oct 11, 2017 at 6:45 AM, Ben Rubinstein via use-livecode <
>>> [hidden email]> wrote:
>>>
>>> You beat me to it!
>>>>
>>>>
>>>> On 11/10/2017 11:23, Ben Rubinstein via use-livecode wrote:
>>>>
>>>> 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
>>>>>>> [hidden email]
>>>>>>> Please visit this url to subscribe, unsubscribe and manage your
>>>>>>> subscription preferences:
>>>>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>> use-livecode mailing list
>>>>>> [hidden email]
>>>>>> Please visit this url to subscribe, unsubscribe and manage your
>>>>>> subscription preferences:
>>>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>> use-livecode mailing list
>>>>> [hidden email]
>>>>> Please visit this url to subscribe, unsubscribe and manage your
>>>>> subscription preferences:
>>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>>>
>>>>>
>>>> _______________________________________________
>>>> use-livecode mailing list
>>>> [hidden email]
>>>> Please visit this url to subscribe, unsubscribe and manage your
>>>> subscription preferences:
>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>>
>>>>
>>>
>>>
>>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>
>
>
> --
> On the first day, God created the heavens and the Earth
> On the second day, God created the oceans.
> On the third day, God put the animals on hold for a few hours,
>    and did a little diving.
> And God said, "This is good."
>



--
On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
   and did a little diving.
And God said, "This is good."
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Dropbox library (LC 9) - does dropboxGetCurrentAccount work?

J. Landman Gay via use-livecode
Ben,
I updated the library and pushed it to my repo.  Let me know if that makes
everything work before I do a PR with LC
https://github.com/macMikey/LCDropboxLibrary

Try it in 8, including the script file as a subscript.  If you want to use
it in 9, copy/paste it into your stack script.

On Wed, Oct 11, 2017 at 9:23 AM, Mike Kerner <[hidden email]>
wrote:

> And, curiously, as it turns out, the other endpoints that take a null post
> accept empty (and don't like getting "null").  It seems this only affects
> getCurrentAccount.
>
> On Wed, Oct 11, 2017 at 8:52 AM, Mike Kerner <[hidden email]>
> wrote:
>
>> What Gerard did in the original library is use the word "null" instead
>> of empty.  So his version of __get_current_account_POST would be
>> private function __get_current_account_POST
>> return "null"
>> end get_current_account_POST
>>
>> For some reason, empty doesn't work, but anything (inluding the word
>> "null") works.
>>
>> Before I make the PR I'm going to see if anything else breaks by doing
>> that, and I'm also going to add the rest of the error message, that gets
>> dropped.
>>
>>
>> On Wed, Oct 11, 2017 at 8:27 AM, Ben Rubinstein via use-livecode <
>> [hidden email]> wrote:
>>
>>> 20555 for POST; 20556 for dropboxGetCurrentAccount.
>>>
>>> I have found the bug in LC's library, and I patched it to get it to work,
>>>> but I want to understand more of why, and also to make sure I'm not
>>>> going
>>>> to break something else before I issue a pull request.
>>>>
>>>
>>> How are you patching it to work? I can't see any way of issuing a POST
>>> request in LC code (without using curl, which won't work on mobile) that
>>> gets round this problem.
>>>
>>>
>>> On 11/10/2017 11:58, Mike Kerner via use-livecode wrote:
>>>
>>>> Feel like opening a couple QR's?  I think we need two:  one for post and
>>>> one for the error in the library.
>>>> In fact, there are two problems in the library.  One is the way the
>>>> library
>>>> handles errors returned by dropbox (you only get half the error
>>>> message),
>>>> and the other is the way endpoints like this one are handled.  Hopefully
>>>> I'll have both of those patched and up to my repo and the PR submitted,
>>>> today.
>>>> If you want, you can also patch the library code, but if you do, I'd
>>>> suggest moving your project to LC8 and including the patched library
>>>> stack
>>>> as a substack.
>>>>
>>>> On Wed, Oct 11, 2017 at 6:45 AM, Ben Rubinstein via use-livecode <
>>>> [hidden email]> wrote:
>>>>
>>>> You beat me to it!
>>>>>
>>>>>
>>>>> On 11/10/2017 11:23, Ben Rubinstein via use-livecode wrote:
>>>>>
>>>>> 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
>>>>>>>> [hidden email]
>>>>>>>> Please visit this url to subscribe, unsubscribe and manage your
>>>>>>>> subscription preferences:
>>>>>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>>>>>>
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>> use-livecode mailing list
>>>>>>> [hidden email]
>>>>>>> Please visit this url to subscribe, unsubscribe and manage your
>>>>>>> subscription preferences:
>>>>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>> use-livecode mailing list
>>>>>> [hidden email]
>>>>>> Please visit this url to subscribe, unsubscribe and manage your
>>>>>> subscription preferences:
>>>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>>>>
>>>>>>
>>>>> _______________________________________________
>>>>> use-livecode mailing list
>>>>> [hidden email]
>>>>> Please visit this url to subscribe, unsubscribe and manage your
>>>>> subscription preferences:
>>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>> _______________________________________________
>>> use-livecode mailing list
>>> [hidden email]
>>> Please visit this url to subscribe, unsubscribe and manage your
>>> subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>
>>
>>
>>
>> --
>> On the first day, God created the heavens and the Earth
>> On the second day, God created the oceans.
>> On the third day, God put the animals on hold for a few hours,
>>    and did a little diving.
>> And God said, "This is good."
>>
>
>
>
> --
> On the first day, God created the heavens and the Earth
> On the second day, God created the oceans.
> On the third day, God put the animals on hold for a few hours,
>    and did a little diving.
> And God said, "This is good."
>



--
On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
   and did a little diving.
And God said, "This is good."
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Dropbox library (LC 9) - does dropboxGetCurrentAccount work?

J. Landman Gay via use-livecode
In reply to this post by J. Landman Gay via use-livecode
Dodgy coding by someone at Dropbox. But there you go!

Thanks for your help,

Ben

On 11/10/2017 14:23, Mike Kerner via use-livecode wrote:

> And, curiously, as it turns out, the other endpoints that take a null post
> accept empty (and don't like getting "null").  It seems this only affects
> getCurrentAccount.
>
> On Wed, Oct 11, 2017 at 8:52 AM, Mike Kerner <[hidden email]>
> wrote:
>
>> What Gerard did in the original library is use the word "null" instead of
>> empty.  So his version of __get_current_account_POST would be
>> private function __get_current_account_POST
>> return "null"
>> end get_current_account_POST
>>
>> For some reason, empty doesn't work, but anything (inluding the word
>> "null") works.
>>
>> Before I make the PR I'm going to see if anything else breaks by doing
>> that, and I'm also going to add the rest of the error message, that gets
>> dropped.
>>
>>
>> On Wed, Oct 11, 2017 at 8:27 AM, Ben Rubinstein via use-livecode <
>> [hidden email]> wrote:
>>
>>> 20555 for POST; 20556 for dropboxGetCurrentAccount.
>>>
>>> I have found the bug in LC's library, and I patched it to get it to work,
>>>> but I want to understand more of why, and also to make sure I'm not going
>>>> to break something else before I issue a pull request.
>>>>
>>>
>>> How are you patching it to work? I can't see any way of issuing a POST
>>> request in LC code (without using curl, which won't work on mobile) that
>>> gets round this problem.
>>>
>>>
>>> On 11/10/2017 11:58, Mike Kerner via use-livecode wrote:
>>>
>>>> Feel like opening a couple QR's?  I think we need two:  one for post and
>>>> one for the error in the library.
>>>> In fact, there are two problems in the library.  One is the way the
>>>> library
>>>> handles errors returned by dropbox (you only get half the error message),
>>>> and the other is the way endpoints like this one are handled.  Hopefully
>>>> I'll have both of those patched and up to my repo and the PR submitted,
>>>> today.
>>>> If you want, you can also patch the library code, but if you do, I'd
>>>> suggest moving your project to LC8 and including the patched library
>>>> stack
>>>> as a substack.
>>>>
>>>> On Wed, Oct 11, 2017 at 6:45 AM, Ben Rubinstein via use-livecode <
>>>> [hidden email]> wrote:
>>>>
>>>> You beat me to it!
>>>>>
>>>>>
>>>>> On 11/10/2017 11:23, Ben Rubinstein via use-livecode wrote:
>>>>>
>>>>> 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
>>>>>>>> [hidden email]
>>>>>>>> Please visit this url to subscribe, unsubscribe and manage your
>>>>>>>> subscription preferences:
>>>>>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>>>>>>
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>> use-livecode mailing list
>>>>>>> [hidden email]
>>>>>>> Please visit this url to subscribe, unsubscribe and manage your
>>>>>>> subscription preferences:
>>>>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>> use-livecode mailing list
>>>>>> [hidden email]
>>>>>> Please visit this url to subscribe, unsubscribe and manage your
>>>>>> subscription preferences:
>>>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>>>>
>>>>>>
>>>>> _______________________________________________
>>>>> use-livecode mailing list
>>>>> [hidden email]
>>>>> Please visit this url to subscribe, unsubscribe and manage your
>>>>> subscription preferences:
>>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>> _______________________________________________
>>> use-livecode mailing list
>>> [hidden email]
>>> Please visit this url to subscribe, unsubscribe and manage your
>>> subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>
>>
>>
>>
>> --
>> On the first day, God created the heavens and the Earth
>> On the second day, God created the oceans.
>> On the third day, God put the animals on hold for a few hours,
>>     and did a little diving.
>> And God said, "This is good."
>>
>
>
>

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Dropbox library (LC 9) - does dropboxGetCurrentAccount work?

J. Landman Gay via use-livecode
Please try to break it so I don't have my name on a PR that LC sends that
breaks someone's mission critical app.

On Wed, Oct 11, 2017 at 10:08 AM, Ben Rubinstein via use-livecode <
[hidden email]> wrote:

> Dodgy coding by someone at Dropbox. But there you go!
>
> Thanks for your help,
>
> Ben
>
>
> On 11/10/2017 14:23, Mike Kerner via use-livecode wrote:
>
>> And, curiously, as it turns out, the other endpoints that take a null post
>> accept empty (and don't like getting "null").  It seems this only affects
>> getCurrentAccount.
>>
>> On Wed, Oct 11, 2017 at 8:52 AM, Mike Kerner <[hidden email]>
>> wrote:
>>
>> What Gerard did in the original library is use the word "null" instead of
>>> empty.  So his version of __get_current_account_POST would be
>>> private function __get_current_account_POST
>>> return "null"
>>> end get_current_account_POST
>>>
>>> For some reason, empty doesn't work, but anything (inluding the word
>>> "null") works.
>>>
>>> Before I make the PR I'm going to see if anything else breaks by doing
>>> that, and I'm also going to add the rest of the error message, that gets
>>> dropped.
>>>
>>>
>>> On Wed, Oct 11, 2017 at 8:27 AM, Ben Rubinstein via use-livecode <
>>> [hidden email]> wrote:
>>>
>>> 20555 for POST; 20556 for dropboxGetCurrentAccount.
>>>>
>>>> I have found the bug in LC's library, and I patched it to get it to
>>>> work,
>>>>
>>>>> but I want to understand more of why, and also to make sure I'm not
>>>>> going
>>>>> to break something else before I issue a pull request.
>>>>>
>>>>>
>>>> How are you patching it to work? I can't see any way of issuing a POST
>>>> request in LC code (without using curl, which won't work on mobile) that
>>>> gets round this problem.
>>>>
>>>>
>>>> On 11/10/2017 11:58, Mike Kerner via use-livecode wrote:
>>>>
>>>> Feel like opening a couple QR's?  I think we need two:  one for post and
>>>>> one for the error in the library.
>>>>> In fact, there are two problems in the library.  One is the way the
>>>>> library
>>>>> handles errors returned by dropbox (you only get half the error
>>>>> message),
>>>>> and the other is the way endpoints like this one are handled.
>>>>> Hopefully
>>>>> I'll have both of those patched and up to my repo and the PR submitted,
>>>>> today.
>>>>> If you want, you can also patch the library code, but if you do, I'd
>>>>> suggest moving your project to LC8 and including the patched library
>>>>> stack
>>>>> as a substack.
>>>>>
>>>>> On Wed, Oct 11, 2017 at 6:45 AM, Ben Rubinstein via use-livecode <
>>>>> [hidden email]> wrote:
>>>>>
>>>>> You beat me to it!
>>>>>
>>>>>>
>>>>>>
>>>>>> On 11/10/2017 11:23, Ben Rubinstein via use-livecode wrote:
>>>>>>
>>>>>> 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/u
>>>>>>> sers/get_current_account
>>>>>>> \
>>>>>>>       --header "Authorization: Bearer <Access Token>"
>>>>>>>
>>>>>>> works and returns the expected data; but
>>>>>>>
>>>>>>> $ curl -X POST https://api.dropboxapi.com/2/u
>>>>>>> sers/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
>>>>>>>>> [hidden email]
>>>>>>>>> Please visit this url to subscribe, unsubscribe and manage your
>>>>>>>>> subscription preferences:
>>>>>>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> _______________________________________________
>>>>>>>>>
>>>>>>>> use-livecode mailing list
>>>>>>>> [hidden email]
>>>>>>>> Please visit this url to subscribe, unsubscribe and manage your
>>>>>>>> subscription preferences:
>>>>>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>>>>>>
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>>
>>>>>>> use-livecode mailing list
>>>>>>> [hidden email]
>>>>>>> Please visit this url to subscribe, unsubscribe and manage your
>>>>>>> subscription preferences:
>>>>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>> use-livecode mailing list
>>>>>> [hidden email]
>>>>>> Please visit this url to subscribe, unsubscribe and manage your
>>>>>> subscription preferences:
>>>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>> use-livecode mailing list
>>>> [hidden email]
>>>> Please visit this url to subscribe, unsubscribe and manage your
>>>> subscription preferences:
>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>>
>>>>
>>>
>>>
>>> --
>>> On the first day, God created the heavens and the Earth
>>> On the second day, God created the oceans.
>>> On the third day, God put the animals on hold for a few hours,
>>>     and did a little diving.
>>> And God said, "This is good."
>>>
>>>
>>
>>
>>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



--
On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
   and did a little diving.
And God said, "This is good."
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Dropbox library (LC 9) - does dropboxGetCurrentAccount work?

J. Landman Gay via use-livecode
In reply to this post by J. Landman Gay via use-livecode
Confessions of ignorance time:
- how do you add a script-only stack as a substack to another stack?

Or does one just past the text into a button or similar and start using it?

This is in relation to 8.  For 9, I simply replaced
        /Contents/Tools/Toolset/libraries/dropbox.livecodescript
inside the app package with your file, and that seemed to work fine.

TIA,

Ben

On 11/10/2017 14:41, Mike Kerner via use-livecode wrote:
> Ben,
> I updated the library and pushed it to my repo.  Let me know if that makes
> everything work before I do a PR with LC
> https://github.com/macMikey/LCDropboxLibrary
>
> Try it in 8, including the script file as a subscript.  If you want to use
> it in 9, copy/paste it into your stack script.
>

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode