Updated 19/03/2013
If server is a must have middle man, then I recon the easiest way is to grab a domain name and make the server go public. www.godaddy.com or any domain name provider will get a domain name for about $15 per year (would be lower if there is discount).
After that then just search how to get a dynamic DNS and setup the redirect_uri as the domain name that has been choose.
Otherwise I didn't see the role of the server is playing here if only for the oauth purpose. As the second method listed below, a device can communicate to google server directly even behind a heavily defenced fire wall. (token will be passed throw the title bar).
So might need some clairification here.
Would the localhost server acting like a hub to cashing files from google drive and then redistribute to iOS devices? Or what kind of network architecture would like to achieve here?
==
Updated 18/03/2013
according to the official document
https://developers.google.com/accounts/docs/OAuth2InstalledApp#choosingredirecturi
There are two ways of oauth. using localhost as redirect is just one way.
another is to use this string
urn:ietf:wg:oauth:2.0:oob
to replace the request where it have local host.
For example, a previous request with localhost of (note: the difference is on the middle line starting with '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 be 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 the url of the former one in the simulator should be equivalent of accessing the latter one in real device.
Halo
Comments:
aloo said:
Google doesn't let you enter non public URLs as redirect URIs in the api console unfortunately
Hao Li said:
Edited my answer, have a try about this one :D
aloo said:
still not sure this works - what url do you put as the redirect_uri?
Hao Li said:
agh.... seems like I understood the question in a different direction. Just post another answer specific for your question. Hope this one helps :D
aloo said:
I still need a redirect to the server though. When I use urn:ietf:wg:oauth:2.0:oob as the redirect_uri, how does it know the url of the server address that I want to redirect to?