Sign In Dropbox using oAuth 2

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
heatherlaine
Site Admin
Site Admin
Posts: 343
Joined: Thu Feb 23, 2006 7:59 pm
Location: Wales

Sign In Dropbox using oAuth 2

Post by heatherlaine » Thu May 15, 2014 10:57 am

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

wimpykid1570
Posts: 10
Joined: Thu May 01, 2014 2:31 pm

Re: Sign In Dropbox using oAuth 2

Post by wimpykid1570 » Tue May 20, 2014 1:12 pm

Anyone can help me on this? Thanks.

wimpykid1570
Posts: 10
Joined: Thu May 01, 2014 2:31 pm

Re: Sign In Dropbox using oAuth 2

Post by wimpykid1570 » Sun Jun 01, 2014 11:09 pm

Anyone can help me on this? Any moderators? Thanks.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Sign In Dropbox using oAuth 2

Post by Simon » Mon Jun 02, 2014 12:03 am

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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Location: Plymouth, UK
Contact:

Re: Sign In Dropbox using oAuth 2

Post by dave.kilroy » Mon Jun 02, 2014 8:30 am

Hi wimpykid1570

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

Kind regards

Dave
"...this is not the code you are looking for..."

wimpykid1570
Posts: 10
Joined: Thu May 01, 2014 2:31 pm

Re: Sign In Dropbox using oAuth 2

Post by wimpykid1570 » Mon Jun 02, 2014 2:51 pm

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

dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Location: Plymouth, UK
Contact:

Re: Sign In Dropbox using oAuth 2

Post by dave.kilroy » Mon Jun 02, 2014 3:08 pm

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
"...this is not the code you are looking for..."

wimpykid1570
Posts: 10
Joined: Thu May 01, 2014 2:31 pm

Re: Sign In Dropbox using oAuth 2

Post by wimpykid1570 » Mon Jun 02, 2014 5:20 pm

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

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Sign In Dropbox using oAuth 2

Post by Klaus » Mon Jun 02, 2014 5:33 pm

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

wimpykid1570
Posts: 10
Joined: Thu May 01, 2014 2:31 pm

Re: Sign In Dropbox using oAuth 2

Post by wimpykid1570 » Fri Jun 13, 2014 3:27 pm

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.

Post Reply

Return to “Talking LiveCode”