views:

336

answers:

2

Hi all

I'm trying to use/understand Google request token mechanism. I intend to use it for an application I've start to develop to access Orkut data using OpenSocial API.

I read this document that explains the steps to obtain a token for an installed application. This document tells you to use the OAuthGetRequestToken method from Google OAuth API to acquire a request token . Accessing the manual of this function (available here). But the parameter oauth_consumer_key, which is required, asks for the "Domain identifying the third-party web application", but I don,t have a domain, it is an installed application.

So my question is, what should I put in this parameter in that case?

I'm using oauth_playground to run my tests.

Thx

+1  A: 

From what i have read in the documentation, the following instruction on getting a request token implies that you simply pass 'anonymous' as the consumer key...

"1.The installed application contacts the Google Authorization service, asking for a request token for one or more Google service. The request is signed using the "anonymous" consumer key/secret." (OAuthForInstalledApps)

Grace
Yes I already read about it and tried to test it using oauth playground (http://googlecodesamples.com/oauth_playground/). It does work with scopes like Open Social but doesn't with Orkut that I'm trying to use. But thanks anyway
Andres
A: 

The trick is to create a hybrid auth process. You register a web app at a domain you own, authorize users for a web app via the OAuth for Web Apps process, then implement a mechanism by which their installed app can pick up that authorization from the web app.

My thinking on this would be that the installed app would send your site a request for a keypair. It would receive an initiate key and an authorize key, both of which you'd store in a database at the web site for one time use.

The app would then use whatever mechanism to launch an external browser, pointing it to yourdomain.com/authorizestart.php?initiate=[initiate code]. The site stores the code in a session variable, then sends the user off to Google to authenticate. When authentication is successful and Google sends the user back with the next token, you store it in the database entry related to the initiate key.

The user closes the browser, clicks a "done" button in your app, and the app then sends a request to yourdomain.com/tokenretrieve.php?authorize=[authorize key]

Your site looks up the Google token and transmits it back, the app completes the Oauth process.

The issue with this is that you have to share the "consumer secret" you created in the registration process with the app. Someone could decompile it or try to capture its output and discover your secret key which is part of the method for encrypting responses from the Google servers. That said, how is that worse than using "anonymous" as your consumer secret?

Greg Bulmash