Application Programming Interface which allows you to communicate with Google services and their integration services. It is useful for third-party to take advantages of API's and even can extend the functionalities of API's. Example of these includes Search, YouTube, Google Spreadsheet, Google Maps, Google Contacts etc. Google API's requires authentication and authorization using OAuth 2.0.
to connect Google API's and it provides various connectors to connect the Google API's and perform the operations that you need. Below is list of connector available in Anypoint Exchange to connect Google API's. • Google Spreadsheets Connector • Google Contacts Connector • Google Tasks Connector • Google Calendar Connector • Google Prediction Connector • Google Contacts RAML • Google Drive RAML
instant API connectivity to Google Spreadsheets API's, which allows you to create, modify or access google docs using OAuth 2.0 authentication. For more details on Google Spreadsheets API, click here. By default, you will not find Google Spreadsheets Connector in your Anypoint Studio. So you can install the connector from Anypoint Exchange. First thing you need to use authorize operation, to generate the token. <google-spreadsheets:config-with-oauth name="Google_Spreadsheets" consumerKey="${gs.clientid}" consumerSecret="${gs.clientsecret}" doc:name="Google Spreadsheets" scope="https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email https://spreadsheets.google.com/feeds https://docs.google.com/feeds https://www.googleapis.com/auth/spreadsheets.readonly https://www.googleapis.com/auth/spreadsheets https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email"> <google-spreadsheets:oauth-callback-config domain="${oauth.host}" path="oauth2callback" async="true"/> </google-spreadsheets:config-with-oauth>
tokenID and it can be read using flow variable #[flowVars['OAuthAccessTokenId']] Once Authorization is successful, you can use any operation can be performed depending on your requirement and make sure you are sending token with every request to Google Spreadsheets API's.
case you need to use authorize operation in one flow and other operation in other flow. In such case you need to use object store to store the tokenID generated during authorize operation and in can retrieve from object store in other flow. <?xml version="1.0" encoding="UTF-8"?> <mule xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:ws="http://www.mulesoft.org/schema/mule/ws" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:context="http://www.springframework.org/schema/context" xmlns:google-spreadsheets="http://www.mulesoft.org/schema/mule/google-spreadsheets" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd http://www.mulesoft.org/schema/mule/google-spreaadsheets http://www.mulesoft.org/schema/mule/google-spreadsheets/current/mule-google-spreadsheets.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-current.xsd http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd http://www.mulesoft.org/schema/mule/ws http://www.mulesoft.org/schema/mule/ws/current/mule-ws.xsd http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd http://www.mulesoft.org/schema/mule/google-spreadsheets http://www.mulesoft.org/schema/mule/google-spreadsheets/current/mule-google-spreadsheets.xsd"> <http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/> <google-spreadsheets:config-with-oauth name="Google_Spreadsheets" consumerKey="${gs.clientid}" consumerSecret="${gs.clientsecret}" doc:name="Google Spreadsheets" scope="https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email https://spreadsheets.google.com/feeds https://docs.google.com/feeds https://www.googleapis.com/auth/spreadsheets.readonly https://www.googleapis.com/auth/spreadsheets https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email"> <google-spreadsheets:oauth-callback-configdomain="${oauth.host}" path="oauth2callback" async="true"/> </google-spreadsheets:config-with-oauth>a <flow name="google-spreadsheet-apiFlow"> <http:listener config-ref="HTTP_Listener_Configuration" path="/authorize" doc:name="HTTP" allowedMethods="GET"/> <google-spreadsheets:authorize config-ref="Google_Spreadsheets" doc:name="Google Spreadsheets" accessTokenUrl=" https://accounts.google.com/o/oauth2/token" authorizationUrl="https://accounts.google.com/o/oauth2/auth"/> <logger message="#[payload]" level="INFO" doc:name="Logger"/> <google-spreadsheets:get-all-cells-as-csvconfig-ref="Google_Spreadsheets" lineSeparator="|" spreadsheet="Employee" worksheet="Employee" accessTokenId="#[flowVars['OAuthAccessTokenId']]" doc:name="Google Spreadsheets"/> <logger message="data fetched. #[payload]" level="INFO" doc:name="Logger"/> </flow> </mule>
https://github.com/mulesoft/google-api-commons Google Calendar: https://github.com/mulesoft/google-calendar-connector Google Contacts: https://github.com/mulesoft/google-contacts-connector Google Cloud Messaging: https://github.com/mulesoft/google-cloud-messaging-connector Google Drive: https://github.com/mulesoft/google-drive-connector Gmail: https://github.com/mulesoft/gmail-connector Google Prediction: https://github.com/mulesoft/google-prediction-connector Google Spreadsheets: https://github.com/mulesoft/google-spreadsheets-connector Google Tasks: https://github.com/mulesoft/google-tasks-connector