<html>
<head>
    <base href="https://docs.jboss.org/author">
            <link rel="stylesheet" href="/author/s/en/2172/19/5/_/styles/combined.css?spaceKey=TEIID&amp;forWysiwyg=true" type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://docs.jboss.org/author/display/TEIID/Google+Spreadsheet+Data+Sources">Google Spreadsheet Data Sources</a></h2>
    <h4>Page  <b>added</b> by             <a href="https://docs.jboss.org/author/display/~van.halbert">Van Halbert</a>
    </h4>
         <br/>
    <div class="notificationGreySide">
         <h1><a name="GoogleSpreadsheetDataSources-"></a><font color="#000000"><b>Google Spreadsheet Data Sources</b></font></h1>

<p><font color="#333333">Authentication to your google account may be done in two ways. ClientLogin (requires login and password) or OAuth (more complicated, requires user to supply refresh token).</font></p>

<p><font color="#333333">Google JCA connector is named teiid-connector-google.rar. The examples include a sample google.xml file. The JCA connector has number of config-properties to drive authentication.&nbsp; The JCA connector connects to exactly one spreadsheet.</font></p>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> <font color="#000000">Config property</font> </th>
<th class='confluenceTh'> <font color="#000000">Description</font> </th>
</tr>
<tr>
<td class='confluenceTd'> <font color="#333333">AuthMethod</font> </td>
<td class='confluenceTd'> <font color="#333333">Method to access Google. This property can be set to one of: ClientLogin, OAuth2. If the setting is ClientLogin it is necessary to provide additional two config properties Username, Password. If the setting is OAuth2 it is necessary to provide RefreshToken.</font> </td>
</tr>
<tr>
<td class='confluenceTd'> <font color="#333333">RefreshToken</font> </td>
<td class='confluenceTd'> <font color="#333333">Use guide below to retrieve RefreshToken. Request access to Google Drive and Spreadsheet API.&nbsp;Applicable only if AuthMethod=OAuth2</font> </td>
</tr>
<tr>
<td class='confluenceTd'> <font color="#333333">Username</font> </td>
<td class='confluenceTd'> <font color="#333333">Username to Google account. Applicable only if AuthMethod=ClientLogin</font> </td>
</tr>
<tr>
<td class='confluenceTd'> <font color="#333333">Password</font> </td>
<td class='confluenceTd'> <font color="#333333">Password to Google account. Applicable only if AuthMethod=ClientLogin</font> </td>
</tr>
<tr>
<td class='confluenceTd'> <font color="#333333">SpreadsheetName</font> </td>
<td class='confluenceTd'> <font color="#333333">Required property with name of the Spreadsheet that is datasource for this connector.</font> </td>
</tr>
<tr>
<td class='confluenceTd'> <font color="#333333">BatchSize</font> </td>
<td class='confluenceTd'> <font color="#333333">Integer that designates how big will be portions of data loaded by this JCA Connector.</font> </td>
</tr>
</tbody></table>
</div>


<h2><a name="GoogleSpreadsheetDataSources-"></a><font color="#000000"><b>Getting an OAuth Refresh Token</b></font></h2>

<p><font color="#333333">Use this request:</font></p>

<p><font color="#005e8f">[<font color="#005e8f"></font>https://accounts.google.com/o/oauth2/auth?scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive+https%3A%2F%2Fspreadsheets.google.com%2Ffeeds&amp;redirect_uri=urn:ietf:wg:oauth:2.0:oob&amp;response_type=code&amp;client_id=217138521084.apps.googleusercontent.com</font>|https://accounts.google.com/o/oauth2/auth?scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive+https%3A%2F%2Fspreadsheets.google.com%2Ffeeds&amp;redirect_uri=urn:ietf:wg:oauth:2.0:oob&amp;response_type=code&amp;client_id=217138521084.apps.googleusercontent.com]<font color=""><br/>
<br/>
<font color="#333333"></font>&nbsp;Then copy the authorization code into following POST request and run it in command line:</font></p>

<p><font color="#333333">curl &#45;-data-urlencode code=&lt;AUTH_CODE&gt; {color}<br/>
<font color="#333333"></font>&#45;-data-urlencode client_id=217138521084.apps.googleusercontent.com {color}<br/>
<font color="#333333"></font>&#45;-data-urlencode client_secret=gXQ6-lOkEjE1lVcz7giB4Poy {color}<br/>
<font color="#333333"></font>&#45;-data-urlencode redirect_uri=urn:ietf:wg:oauth:2.0:oob {color}<br/>
<font color="#333333"></font>&#45;-data-urlencode grant_type=authorization_code [https://accounts.google.com/o/oauth2/token]</font><br/>
<font color="#333333">The refresh token will be in the response</font></p>

<h2><a name="GoogleSpreadsheetDataSources-"></a><font color="#000000"><b>Implementation Details</b></font></h2>

<p><font color="#333333">Google Translator is implemented using GData API [1] (java library for [4]) and Google Visualization Protocol [2]. Authentication is implemented using OAuth2 for devices [3].</font></p>
<ol>
        <li><font color="#005e8f">[<font color="#005e8f"></font>https://developers.google.com/google-apps/spreadsheets/</font>|https://developers.google.com/google-apps/spreadsheets/]<font color=""><br/>
# <font color="#005e8f"></font>[<font color="#005e8f"></font>https://developers.google.com/chart/interactive/docs/querylanguage</font>|https://developers.google.com/chart/interactive/docs/querylanguage]<font color=""><br/>
# <font color="#005e8f"></font>[<font color="#005e8f"></font>https://developers.google.com/accounts/docs/OAuth2ForDevices</font>|https://developers.google.com/accounts/docs/OAuth2ForDevices]<font color=""><br/>
# <font color="#005e8f"></font>[<font color="#005e8f"></font>https://developers.google.com/google-apps/spreadsheets/</font>|https://developers.google.com/google-apps/spreadsheets/]<font color=""></font></li>
</ol>

    </div>
    <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;" class="grey">
                        <a href="https://docs.jboss.org/author/users/removespacenotification.action?spaceKey=TEIID">Stop watching space</a>
            <span style="padding: 0px 5px;">|</span>
                <a href="https://docs.jboss.org/author/users/editmyemailsettings.action">Change email notification preferences</a>
</div>
       <a href="https://docs.jboss.org/author/display/TEIID/Google+Spreadsheet+Data+Sources">View Online</a>
              |
       <a href="https://docs.jboss.org/author/display/TEIID/Google+Spreadsheet+Data+Sources?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
           </div>
</div>
</div>
</div>
</div>
</body>
</html>