oauth 2.0 - Using Google Oauth2 webflow from iOS + Bonjour (Yikes!) -


i'm building ios app requires user authorize google api's via oauth2 using server side web flow. open uiwebview start oauth2 flow.

this works fine in simulator because i'm setting redirect uri http://localhost , have server running on local machine.

however, i'd test on device while still connecting server running on desktop. in order this, i've gotten app discover desktop address (a local subnet ip or bonjour address http://foo.local.) connect server. however, google oauth2 flow saying cannot use local uri's redirect url.

is there way around this? i'd not have mess local network setup or proxy requests ios device if @ possible. i'd ideally able use bonjour service discover server because have team of developers , our app lets choose server on local network you'd connect to.

options?

updated 19/03/2013

if server must have middle man, recon easiest way grab domain name , make server go public. www.godaddy.com or domain name provider domain name $15 per year (would lower if there discount).

after search how dynamic dns , setup redirect_uri domain name has been choose.

otherwise didn't see role of server playing here if oauth purpose. second method listed below, device can communicate google server directly behind heavily defenced fire wall. (token passed throw title bar).

so might need clairification here.

would localhost server acting hub cashing files google drive , redistribute ios devices? or kind of network architecture achieve here?

==

updated 18/03/2013

according official document https://developers.google.com/accounts/docs/oauth2installedapp#choosingredirecturi

there 2 ways of oauth. using localhost redirect 1 way.

another use string

urn:ietf:wg:oauth:2.0:oob 

to replace request have local host.

for example, previous request localhost of (note: difference on middle line starting 'redirect_uri=')

    https://accounts.google.com/o/oauth2/auth?scope=https%3a%2f%2fwww.googleapis.com%2fauth%2fuserinfo.email+https%3a%2f%2fwww.googleapis.com%2fauth%2fuserinfo.profile& redirect_uri=http://localhost:9004& response_type=code&client_id=812741506391-h38jh0j4fv0ce1krdkiq0hfvt6n5amrf.apps.googleusercontent.com 

now can changed to

    https://accounts.google.com/o/oauth2/auth?scope=https%3a%2f%2fwww.googleapis.com%2fauth%2fuserinfo.email+https%3a%2f%2fwww.googleapis.com%2fauth%2fuserinfo.profile& redirect_uri=urn:ietf:wg:oauth:2.0:oob& response_type=code&client_id=812741506391-h38jh0j4fv0ce1krdkiq0hfvt6n5amrf.apps.googleusercontent.com 

so access url of former 1 in simulator should equivalent of accessing latter 1 in real device.

halo


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -