tags:

views:

75

answers:

0

Hi,

I am trying to implement the OpenID + OAuth protocol using java in my web application.

I am allowing user to login using the Google openID and i want to embed the Google calendar with that email id which has been logged in.

I was created the following code, know i was successfully authenticated and i am getting the values of openID exchange attributes properly like email, first name and last name. But i was unable to get the OAuth request_token.

My Code is :

ConsumerManager manager = new ConsumerManager();
            List discoveries = manager.discover("https://www.google.com/accounts/o8/id");
            DiscoveryInformation discovered = manager.associate(discoveries);
            AuthRequest authReq = manager.authenticate(discovered, "http://localhost:8080/Sample/OAuthOpenIDSuccess", "http://localhost:8080/Sample");

            //--- OAuth parameters for getting access tokens for other third party google services ---.
            HybridOauthMessage hybridMsg = new HybridOauthMessage();
            ParameterList paramsList = hybridMsg.getParameters();
            //ParameterList paramsList = new ParameterList();
            Parameter param1 = new Parameter("scope", "http://www.google.com/calendar/feeds/");
            Parameter param2 = new Parameter("consumer", "http://localhost:8080/Sample");
            paramsList.set(param1);
            paramsList.set(param2);
            Message message = authReq.createMessage(paramsList);

            if (true)
            {
             //-- only fetch for subscriber signUp page, not needed for login page --.
             FetchRequest fetch = FetchRequest.createFetchRequest();
             fetch.addAttribute("email", "http://schema.openid.net/contact/email", true);
             fetch.addAttribute("firstname", "http://axschema.org/namePerson/first", true);
             fetch.addAttribute("lastname", "http://axschema.org/namePerson/last", true);
             authReq.addExtension(fetch);
            }
            authReq.addExtension(hybridMsg);

            String returnStr;
            if (!discovered.isVersion2())
            {
                returnStr = authReq.getDestinationUrl(true);
            }
            else
            {
                returnStr = authReq.getDestinationUrl(false);
            }

After sucessfull authentication i am trying to get the data

req.getParameter("openid.ext1.value.email");
req.getParameter("openid.ext2.request_token");

from above i am getting the email properly not request_token I am refering to Google's Federated Login page http://code.google.com/apis/accounts/docs/OpenID.html#oauth

give any idea how can i resolve this issue.

Thanks.