Class GoogleTemplate
- java.lang.Object
-
- org.springframework.social.oauth2.AbstractOAuth2ApiBinding
-
- org.springframework.social.google.api.impl.GoogleTemplate
-
- All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean,org.springframework.social.ApiBinding,Google
public class GoogleTemplate extends org.springframework.social.oauth2.AbstractOAuth2ApiBinding implements Google
The central class for interacting with Google APIs.
Most of the APIs, specifically all GData APIs and Google+ usage of "me", require OAuth2 authentication. To use methods that require OAuth2 authentication,
GoogleTemplatemust be constructed with an access token which is authorized for the appropriate scope. For using Google+ without authenticating,GoogleTemplatedefault constructor can be used.- Author:
- Gabriel Axel
-
-
Constructor Summary
Constructors Constructor Description GoogleTemplate()Creates a new instance of GoogleTemplate.GoogleTemplate(String accessToken)Creates a new instance of GoogleTemplate.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CalendarOperationscalendarOperations()RetrievesCalendarOperations, used for interacting with Google Calendar API.DriveOperationsdriveOperations()RetrievesDriveOperations, used for interacting with Google Drive API.StringgetAccessToken()Returns the access token, allowing interoperability with other librariesprotected List<org.springframework.http.converter.HttpMessageConverter<?>>getMessageConverters()protected org.springframework.social.oauth2.OAuth2VersiongetOAuth2Version()OAuth2Operationsoauth2Operations()RetrievesOAuth2Operations, used for interacting with Google+ API.PeopleOperationspeopleOperations()RetrievesPeopleOperations, used for interacting with Google People API.PlusOperationsplusOperations()RetrievesPlusOperations, used for interacting with Google+ API.org.springframework.web.client.RestOperationsrestOperations()TaskOperationstaskOperations()RetrievesTaskOperations, used for interacting with Google Tasks API.-
Methods inherited from class org.springframework.social.oauth2.AbstractOAuth2ApiBinding
afterPropertiesSet, configureRestTemplate, getByteArrayMessageConverter, getFormMessageConverter, getJsonMessageConverter, getRestTemplate, isAuthorized, postConstructionConfiguration, postProcess, setRequestFactory
-
-
-
-
Constructor Detail
-
GoogleTemplate
public GoogleTemplate()
Creates a new instance of GoogleTemplate. This constructor creates a new GoogleTemplate able to perform unauthenticated operations against Google+.
-
GoogleTemplate
public GoogleTemplate(String accessToken)
Creates a new instance of GoogleTemplate. This constructor creates the FacebookTemplate using a given access token.- Parameters:
accessToken- an access token granted by Google after OAuth2 authentication
-
-
Method Detail
-
getMessageConverters
protected List<org.springframework.http.converter.HttpMessageConverter<?>> getMessageConverters()
- Overrides:
getMessageConvertersin classorg.springframework.social.oauth2.AbstractOAuth2ApiBinding
-
getOAuth2Version
protected org.springframework.social.oauth2.OAuth2Version getOAuth2Version()
- Overrides:
getOAuth2Versionin classorg.springframework.social.oauth2.AbstractOAuth2ApiBinding
-
plusOperations
public PlusOperations plusOperations()
Description copied from interface:GoogleRetrievesPlusOperations, used for interacting with Google+ API. Some methods require OAuth2 scope https://www.googleapis.com/auth/plus.me- Specified by:
plusOperationsin interfaceGoogle- Returns:
PlusOperationsfor the authenticated user if authenticated
-
taskOperations
public TaskOperations taskOperations()
Description copied from interface:GoogleRetrievesTaskOperations, used for interacting with Google Tasks API. Requires OAuth scope https://www.googleapis.com/auth/tasks or https://www.googleapis.com/auth/tasks.readonly- Specified by:
taskOperationsin interfaceGoogle- Returns:
TaskOperationsfor the authenticated user
-
driveOperations
public DriveOperations driveOperations()
Description copied from interface:GoogleRetrievesDriveOperations, used for interacting with Google Drive API. Requires OAuth scope(s) from the following:- https://www.googleapis.com/auth/drive.file
- https://www.googleapis.com/auth/drive
- https://www.googleapis.com/auth/drive.apps.readonly
- https://www.googleapis.com/auth/drive.readonly
- https://www.googleapis.com/auth/drive.readonly.metadata
- Specified by:
driveOperationsin interfaceGoogle- Returns:
DriveOperationsfor the authenticated user
-
calendarOperations
public CalendarOperations calendarOperations()
Description copied from interface:GoogleRetrievesCalendarOperations, used for interacting with Google Calendar API. Some methods require OAuth2 scope from the following:- https://www.googleapis.com/auth/calendar.readonly
- https://www.googleapis.com/auth/calendar
- Specified by:
calendarOperationsin interfaceGoogle- Returns:
CalendarOperationsfor the authenticated user if authenticated
-
peopleOperations
public PeopleOperations peopleOperations()
Description copied from interface:GoogleRetrievesPeopleOperations, used for interacting with Google People API. Some methods require OAuth2 scope https://people.googleapis.com/v1/me- Specified by:
peopleOperationsin interfaceGoogle- Returns:
PeopleOperationsfor the authenticated user if authenticated
-
getAccessToken
public String getAccessToken()
Description copied from interface:GoogleReturns the access token, allowing interoperability with other libraries- Specified by:
getAccessTokenin interfaceGoogle- Returns:
- The OAuth2 access token
- See Also:
- Google APIs Client Library for Java
-
oauth2Operations
public OAuth2Operations oauth2Operations()
Description copied from interface:GoogleRetrievesOAuth2Operations, used for interacting with Google+ API.- Specified by:
oauth2Operationsin interfaceGoogle- Returns:
PlusOperationsfor the authenticated user if authenticated
-
restOperations
public org.springframework.web.client.RestOperations restOperations()
- Specified by:
restOperationsin interfaceGoogle
-
-