Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>After looking at some of the Google Calendar API's and examples it looks like the best way to assign a token to the Calendar is when initializing it. This takes some setup, take a look at this link:</p> <p><a href="https://developers.google.com/google-apps/calendar/instantiate" rel="nofollow">https://developers.google.com/google-apps/calendar/instantiate</a></p> <p>My apologies if you have already been through it, but it looks like you may be able to make a few adjustments to that example. </p> <p>Right before the Calendar is initialized, this snipped of code is executed:</p> <pre><code> GoogleAccessProtectedResource accessProtectedResource = new GoogleAccessProtectedResource( response.accessToken, httpTransport, jsonFactory, clientId, clientSecret, response.refreshToken); </code></pre> <p>which in turn is used as part of the Calendars initialization.</p> <p>Looking at the documentation for GoogleAccessProtectedResource it looks like there exists a constructor which just takes in an access token.</p> <p><a href="http://javadoc.google-api-java-client.googlecode.com/hg/1.4.1-beta/com/google/api/client/googleapis/auth/oauth2/draft10/GoogleAccessProtectedResource.html#GoogleAccessProtectedResource(java.lang.String)" rel="nofollow">http://javadoc.google-api-java-client.googlecode.com/hg/1.4.1-beta/com/google/api/client/googleapis/auth/oauth2/draft10/GoogleAccessProtectedResource.html#GoogleAccessProtectedResource(java.lang.String)</a></p> <p>You can use the tokens that you have already requested in your method before, then with a couple other objects described in the google calendar instantiate link above, you should be able to properly instantiate the calendar with the given access token.</p> <p>Hope this helps,</p> <p><strong>EDIT</strong></p> <p>It looks like the GoogleAccessProtectedResource is actually going to be deprecated, or already is.</p> <p>The javadoc states:</p> <p>"Deprecated. (scheduled to be removed in 1.8) Use GoogleCredential"</p> <p><a href="http://javadoc.google-api-java-client.googlecode.com/hg/1.7.0-beta/com/google/api/client/googleapis/auth/oauth2/draft10/GoogleAccessProtectedResource.html" rel="nofollow">http://javadoc.google-api-java-client.googlecode.com/hg/1.7.0-beta/com/google/api/client/googleapis/auth/oauth2/draft10/GoogleAccessProtectedResource.html</a></p> <p>So it looks like what you will need is GoogleCredential to replace GoogleAccessProtectedResource. I found that you can setup a credential with an access token like so:</p> <pre><code>GoogleCredential credential = new GoogleCredential().setAccessToken(accessToken); </code></pre> <p>Then you can create the new calendar by doing this:</p> <pre><code>Calendar service = new Calendar.Builder(httpTransport, jsonFactory, credential).build(); </code></pre> <p>Where the httpTransport and jsonFactory would be similar to what the other example had.</p> <p>Good Luck!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload