liferay/liferay-plugins — pull request #48 by ivicac (2012-05-15 23:00:09+00:00)
Title: Lps 26751- Open Social gadgets deployed to other gadget containers looking to leverage Liferay web services should authenticate via OAuth.

Hi Ray,
this is initial commit so you can to see if we are going to right direction. :)

The base are three struts actions: OAuthRequestTokenAction, OAuthAuthorizeAction and OAuthAccessTokenAction.

Before you start, after you deploy oauth-web plugin you should insert one row in oauthapplication table:

INSERT INTO `lportal62_dev`.`oauthapplication` (`applicationId`, `companyId`, `userId`, `userName`, `consumerKey`, `consumerSecret`, `callBackURL`) VALUES (1, 1, 1, 'test', 'key11', 'secret11', 'http://www.liferay.com');

Two tables are created: oauthapplication and oauthapplications_users

After that you are ready to call little comand line program I wrote(at the and it should become a junit test, but for now it is a smal utility).

You should call it via:

java -cp .:/Volumes/Data/development/projects/liferay/trunk/portal/lib/portal/* com.liferay.portal.oauth.OAuthProviderTest

After program starts it will call first action OAuthRequestTokenAction that will return you first temporary token.

After that you will get printed url you need to call from browser, something like:

http://localhost:8080/c/portal/oauth/authorize?oauth_token=f093ac1b104c89c6f2eecc3610b6b479. this will call second action: OAuthAuthorizeAction

One notice here, If you are not logged in, after you login you will not be redirected(what I need to do to fix that?)

You will get a page for grantig acces to your data(this page also is not finalized, it is only for testing now).

After you click button for granting access you will be redirected to callback url something like:

http://www.liferay.com/?oauth_token=f093ac1b104c89c6f2eecc3610b6b479&oauth_verifier=7053b32544a5c9e4bd7e35f2e302bd52

Before redirecting, in oauthapplicatios_users table will be written true to aouthorized column

Then you go back and type value of oauth_verifier parameter from the last step in the console.

Afetr that utility calls the last action OAuthAccessTokenAction and as a result you will get access token printen in the console and token secret(it is not printed).

On the server side they wll be written in oauthapplications_user table.

All temporay tokens, secretsand nonces are in memory, only final access token and secret is written to database.

Igor is still working on CP portlets for oauth so you will get that later unfortunatelly.

So if you have any questions, I am listening and waiting for your answer:)

Best Regards