0
votes

I'm treading in unfamiliar territory again.

I used this client library https://code.google.com/p/gwt-oauth2/ to get an access token that I can use to access google calendar API.

After doing some research, I noticed another client library http://code.google.com/p/gwt-google-apis/source/browse/trunk/apis/samples/calendar/com/google/api/gwt/samples/calendar/client/CalendarEntryPoint.java that I can use to make google calendar api calls.

Now what I don't understand is how to combine the two. So I have an access token now, but the sample code from the second client library does not use that access token anywhere (it only uses the client_id and api_key from the google api console).

Are these two libraries mutually exclusive or are they meant to work together?

EDIT:

What I want to achieve is to authorize my application's access to Google calendars using the first library, and make API calls using the second. The trouble is, when I make API calls with the second library, it doesn't recognize that my application is already authorized to use Google Calendars, I believe the trouble is with this line from the sample code:

calendar.initialize(new SimpleEventBus(),
    new GoogleApiRequestTransport(APPLICATION_NAME, API_KEY));

When this call is made, it registers a second application (I can see this from my third party apps in my google account). Even though the first application is already authorized to use Google calendars, the newly registered application wants to be authorized again.

So I looked around to see if there is a GoogleApiRequestTransport that can use an existing application, and I managed to find this: http://gwt-google-apis.googlecode.com/svn-history/r1914/trunk/apis/javadoc/latest/javadoc/com/google/api/gwt/shared/GoogleApiRequestTransport.html

This GoogleApiRequestTransport lets me set the access token (which is what I wanted in the first place). But it is a deprecated. So I don't know what to make of it.

2

2 Answers

1
votes

I'll preface this by saying my Java knowledge is non-existent. The second library you point out actually does Oauth2 authentication as well. In this code block (starting at line 75):

private void login() {
  OAuth2Login.get().authorize(CLIENT_ID, CalendarAuthScope.CALENDAR,
      new Callback<Void, Exception>() {
        @Override
        public void onSuccess(Void v) {
          getCalendarId();
        }
        @Override
        public void onFailure(Exception e) {
          GWT.log("Auth failed:", e);
        }
      });
}

You can see a call to OAuth2Login.get().authorize(), which is the process that will generate an access token similar to what you saw with the first library (again, my familiarity with Java is limiting my utility here). Long story short, it appears that the same Oauth2 process is still being implemented, so to answer your original question, these two libraries are basically two ways of accomplishing the same thing - the first just handles the Oauth2 interaction, but the second provides a full package to interact with the APIs themselves.

0
votes

I just documented my successful approach to integrating Google Calendar. I couldn't find any documentation to access calendars without using Google libraries. So I wrote my own:

http://www.tqis.com/eloquency/googlecalendar.htm