Hello Alain,

Even I'm facing the similar problem, ( irrespective of which service I
use ).

It would be nice to have a look at some working Java code . No code
sample (for web apps + gdata + OAuth ) has been bundled
with the samples !

Regards,
Shoubhik Bose.


On Jun 10, 8:53 pm, Alain Vongsouvanh <[email protected]> wrote:
> Hello,
>
> Is this related to the Calendar API? You mentioned trying to retrieve
> "Contacts" (which is not the API being supported in this forum) and your
> code shows that you are trying to retrieve Docs.
> Also, try to print the message returned by the exception as it might give
> more information as to what is wrong with your code.
>
> Best,
> Alain
>
>
>
>
>
>
>
>
>
> On Thu, Jun 9, 2011 at 12:12 AM, manoj <[email protected]> wrote:
> > Hi,
>
> > I am trying to create a simple app on the app engine where users log
> > in through their Google account, and then it adds an event to their
> > calendar.
> > And I am using Java along with Eclipse for this. I have found a simple
> > code online:
>
> > public void doGet(HttpServletRequest req, HttpServletResponse resp)
> >        throws ServletException, IOException {
> >                // Create an instance of GoogleOAuthParameters
> >                GoogleOAuthParameters oauthParameters = new
> > GoogleOAuthParameters();
> >                oauthParameters.setOAuthConsumerKey(CONSUMER_KEY);
> >                oauthParameters.setOAuthConsumerSecret(CONSUMER_SECRET);
> >                oauthParameters.setScope("http://docs.google.com/feeds/";);
>
> >                GoogleOAuthHelper oauthHelper = new GoogleOAuthHelper(
> >                                new OAuthHmacSha1Signer());
>
> >                // Remember the token secret that we stashed? Let's get it
> > back
> >                // now. We need to add it to oauthParameters
> >                String oauthTokenSecret = (String)
> > req.getSession().getAttribute(
> >                "oauthTokenSecret");
> >                oauthParameters.setOAuthTokenSecret(oauthTokenSecret);
>
> >                // The query string should contain the oauth token, so we
> > can just
> >                // pass the query string to our helper object to correctly
> >                // parse and add the parameters to our instance of
> > oauthParameters
>
> >  oauthHelper.getOAuthParametersFromCallback(req.getQueryString(),
> >                                oauthParameters);
>
> >                try {
>
> >                        // Now that we have all the OAuth parameters we
> > need, we can
> >                        // generate an access token and access token secret.
> > These
> >                        // are the values we want to keep around, as they
> > are
> >                        // valid for all API calls in the future until a
> > user revokes
> >                        // our access.
> >                        String accessToken =
> > oauthHelper.getAccessToken(oauthParameters);
> >                        String accessTokenSecret =
> > oauthParameters.getOAuthTokenSecret();
>
> >                        // In a real application, we want to redirect the
> > user to a new
> >                        // servlet that makes API calls. For the safe of
> > clarity and
> > simplicity,
> >                        // we'll just reuse this servlet for making API
> > calls.
> >                        oauthParameters = new GoogleOAuthParameters();
> >                        oauthParameters.setOAuthConsumerKey(CONSUMER_KEY);
>
> >  oauthParameters.setOAuthConsumerSecret(CONSUMER_SECRET);
>
> >                        // This is interesting: we set the OAuth token and
> > the token secret
> >                        // to the values extracted by oauthHelper earlier.
> > These values are
> >                        // already in scope in this example code, but they
> > can be populated
> >                        // from reading from the datastore or some other
> > persistence
> > mechanism.
> >                        oauthParameters.setOAuthToken(accessToken);
>
> >  oauthParameters.setOAuthTokenSecret(accessTokenSecret);
> >                        oauthParameters.setOAuthCallback("
> >http://www.facebook.com";);
>
> >  oauthHelper.getUnauthorizedRequestToken(oauthParameters);
>
> >                        // Create an instance of the DocsService to make API
> > calls
> >                        DocsService client = new DocsService("Malware
> > Inc.");
>
> >                        // Use our newly built oauthParameters
> >                        client.setOAuthCredentials(oauthParameters, new
> > OAuthHmacSha1Signer());
>
> >                        URL feedUrl = new URL("
> >https://docs.google.com/feeds/default/
> > private/full");
> >                        DocumentListFeed resultFeed =
> > client.getFeed(feedUrl,
> >                                        DocumentListFeed.class);
> >                        for (DocumentListEntry entry :
> > resultFeed.getEntries()) {
>
> >  resp.getWriter().println(entry.getTitle().getPlainText());
> >                        }
>
> >                } catch (OAuthException e) {
> >                        // Something went wrong. Usually, you'll end up here
> > if we have
> > invalid
> >                        // oauth tokens
> >                        resp.getWriter().println("Here is the problem");
> >                        //Server shows 500 problem
> >                } catch (ServiceException e) {
> >                        // Handle this exception
> >                }
> >        }
>
> > I have registered my application and added the KEY and Secret above
> > the function, but when I deploy it to the app engine it gives a 500
> > server error.
> > Could someone post a simple java program that uses gdata and oauth to
> > log in a Google user and print the contacts on the screen?
> > Thanks.
>
> > -Manoj
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Google Calendar Data API" group.
> > To post to this group, send email to
> > [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]
> > For more options, visit this group at
> >http://code.google.com/apis/calendar/community/forum.html
>
> --
> Alain Vongsouvanh

-- 
You received this message because you are subscribed to the Google
Groups "Google Calendar Data API" group.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://code.google.com/apis/calendar/community/forum.html

Reply via email to