Page 1 of 1

Sign In Dropbox using oAuth 2

Posted: Thu May 15, 2014 10:57 am
by heatherlaine
I'm posting this on behalf of wimpykid1570, who is a new member and hence unable as yet to post urls.

Hi,
I tried to sign in my dropbox account using oAuth 2 from a desktop app on Windows 8.1.

1. I don't have IIS installed so I don't have a localhost and I don't want to use an external link for redirect_uri. What should I put in for redirect_uri which is a required field? Can I use a variable or a local file path so that I can retrieve my access code?

2. I tried to detect when dropbox redirect to my redirect_uri (which now I use a fake one) so that I can look at the response header, but the browserBeforeNavigate does not get triggered.

Thanks in advance for any ideas or suggestions.

on mouseUp
put "xxxxxxx" into tAppKey
put base64Encode(randomBytes(16)) into tCSRFToken

put "https://www.dropbox.com/1/oauth2/authorize?" & \
"response_type=token&" & \
"state=" & tCSRFToken & "&" & \
"client_id=" & tAppKey & "&" & \
"redirect_uri=SOME_THING" \
into tRequest

put revBrowserOpen((the windowId of this stack), tRequest) into tBrowserId
revBrowserSet tBrowserId, "showborder", "true"
revBrowserSet tBrowserId, "rect", the rectangle of image "MyImage"
end mouseUp

on browserBeforeNavigate bBrowserId, pURL
if "dropbox.com" is not in pURL then
put true into browserCancel
end if
end browserBeforeNavigate


Toan

Re: Sign In Dropbox using oAuth 2

Posted: Tue May 20, 2014 1:12 pm
by wimpykid1570
Anyone can help me on this? Thanks.

Re: Sign In Dropbox using oAuth 2

Posted: Sun Jun 01, 2014 11:09 pm
by wimpykid1570
Anyone can help me on this? Any moderators? Thanks.

Re: Sign In Dropbox using oAuth 2

Posted: Mon Jun 02, 2014 12:03 am
by Simon
Hi wimpykid1570,
I don't know if this thread is of any use to you but check it out:
http://forums.runrev.com/phpBB2/viewtop ... =4&t=12549
Guglielmo's great stack.

Simon

Re: Sign In Dropbox using oAuth 2

Posted: Mon Jun 02, 2014 8:30 am
by dave.kilroy
Hi wimpykid1570

As Simon says, check out Guglielmo's library - I use it a lot and it works brilliantly

Kind regards

Dave

Re: Sign In Dropbox using oAuth 2

Posted: Mon Jun 02, 2014 2:51 pm
by wimpykid1570
Thanks for the quick responses.

I already checked that stack a while ago. It uses oAuth 1.0, not oAuth 2.0. I need to implement something like that in oAuth 2.0.

Anyone has some livecode samples that use oAuth 2.0?

Thanks again,
Toan

Re: Sign In Dropbox using oAuth 2

Posted: Mon Jun 02, 2014 3:08 pm
by dave.kilroy
Hi Toan

Ah, didn't clock the oAuth 2.0 part of what you needed ... I suspect Monte's external is also oAuth 1.0 but his work is definitely worth checking out: http://mergext.com/home/mergdropbox/

Dave

Re: Sign In Dropbox using oAuth 2

Posted: Mon Jun 02, 2014 5:20 pm
by wimpykid1570
Thanks Dave,

Actually, I am not that concerned about oAuth 2 since I know how to do that part ouside of LiveCode. I can do that in ASP.NET or cUrl.

I just want to know how to solve #2. Why doesnt' browserBeforeNavigate work? It does not detect an URL change after I signed in Dropbox. If you or anyone can make that part works or explain me why it would not work, I appreciate the help.

Thanks.
Toan

Re: Sign In Dropbox using oAuth 2

Posted: Mon Jun 02, 2014 5:33 pm
by Klaus
Hi Toan,

sorrry, no idea about this stuff, but two observations:

1. you you did not define tBrowserID as a local or global variable!
2. In your script you use tBrowserID
...
put revBrowserOpen((the windowId of this stack), tRequest) into tBrowserId
...
And then later bBrowserID
...
on browserBeforeNavigate bBrowserId, pURL
...


Best

Klaus

Re: Sign In Dropbox using oAuth 2

Posted: Fri Jun 13, 2014 3:27 pm
by wimpykid1570
Thanks for the suggestion.

But now it drills down to the browser itself not working consistently. I just posted a new topic for that matter at http://forums.livecode.com/viewtopic.php?f=8&t=20762.