<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>edited</b> by             <a href="https://docs.jboss.org/author/display/~shawkins">Steven Hawkins</a>
    </h4>
        <br/>
                         <h4>Changes (8)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >| {color:#333333}Password{color} | {color:#333333}Password to Google account. Applicable only if AuthMethod=ClientLogin{color} | <br>| {color:#333333}SpreadsheetName{color} | {color:#333333}Required property with name of the Spreadsheet that is datasource for this connector.{color} | <br></td></tr>
            <tr><td class="diff-changed-lines" >| {color:#333333}BatchSize{color} | {color:#333333}Integer that designates how big will be portions of data loaded by this JCA <span class="diff-changed-words">Connector.<span class="diff-added-chars"style="background-color: #dfd;">  Defaults to 1000.</span>{color}</span> | <br></td></tr>
            <tr><td class="diff-unchanged" > <br>h2. {color:#000000}{*}Getting an OAuth Refresh Token{*}{color} <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >{color:#333333}Use this request:{color} <br> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">{color:#005e8f}[{color:#005e8f}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{color}|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]{color} <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">[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] <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-changed-words"><span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">{color:#333333}</span>&amp;nbsp;Then</span> copy the authorization code into following POST request and run it in command <span class="diff-changed-words">line:<span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">{color}</span></span> <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">{color:#333333}curl \--data-urlencode code=&lt;AUTH_CODE&gt; \{color} <br>{color:#333333}\--data-urlencode client_id=217138521084.apps.googleusercontent.com \{color} <br>{color:#333333}\--data-urlencode client_secret=gXQ6-lOkEjE1lVcz7giB4Poy \{color} <br>{color:#333333}\--data-urlencode redirect_uri=urn:ietf:wg:oauth:2.0:oob \{color} <br>{color:#333333}\--data-urlencode grant_type=authorization_code \[https://accounts.google.com/o/oauth2/token\]{color} <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{code}curl \--data-urlencode code=&lt;AUTH_CODE&gt; \ <br>--data-urlencode client_id=217138521084.apps.googleusercontent.com \ <br>--data-urlencode client_secret=gXQ6-lOkEjE1lVcz7giB4Poy \ <br>--data-urlencode redirect_uri=urn:ietf:wg:oauth:2.0:oob \ <br>--data-urlencode grant_type=authorization_code https://accounts.google.com/o/oauth2/token{code} <br></td></tr>
            <tr><td class="diff-unchanged" >{color:#333333}The refresh token will be in the response{color} <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" > <br>{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\].{color} <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;"># {color:#005e8f}[{color:#005e8f}https://developers.google.com/google-apps/spreadsheets/{color}|https://developers.google.com/google-apps/spreadsheets/]{color} <br># {color:#005e8f}[{color:#005e8f}https://developers.google.com/chart/interactive/docs/querylanguage{color}|https://developers.google.com/chart/interactive/docs/querylanguage]{color} <br># {color:#005e8f}[{color:#005e8f}https://developers.google.com/accounts/docs/OAuth2ForDevices{color}|https://developers.google.com/accounts/docs/OAuth2ForDevices]{color} <br># {color:#005e8f}[{color:#005e8f}https://developers.google.com/google-apps/spreadsheets/{color}|https://developers.google.com/google-apps/spreadsheets/]{color} <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">1. [https://developers.google.com/google-apps/spreadsheets/] <br>2. [https://developers.google.com/chart/interactive/docs/querylanguage] <br>3. [https://developers.google.com/accounts/docs/OAuth2ForDevices] <br>4. [https://developers.google.com/google-apps/spreadsheets] <br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <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.  Defaults to 1000.</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><a href="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" class="external-link" rel="nofollow">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</a></p>

<p>&nbsp;Then copy the authorization code into following POST request and run it in command line:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">curl \--data-urlencode code=&lt;AUTH_CODE&gt; \
--data-urlencode client_id=217138521084.apps.googleusercontent.com \
--data-urlencode client_secret=gXQ6-lOkEjE1lVcz7giB4Poy \
--data-urlencode redirect_uri=urn:ietf:wg:oauth:2.0:oob \
--data-urlencode grant_type=authorization_code https://accounts.google.com/o/oauth2/token</pre>
</div></div>
<p><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><br/>
1. <a href="https://developers.google.com/google-apps/spreadsheets/" class="external-link" rel="nofollow">https://developers.google.com/google-apps/spreadsheets/</a><br/>
2. <a href="https://developers.google.com/chart/interactive/docs/querylanguage" class="external-link" rel="nofollow">https://developers.google.com/chart/interactive/docs/querylanguage</a><br/>
3. <a href="https://developers.google.com/accounts/docs/OAuth2ForDevices" class="external-link" rel="nofollow">https://developers.google.com/accounts/docs/OAuth2ForDevices</a><br/>
4. <a href="https://developers.google.com/google-apps/spreadsheets" class="external-link" rel="nofollow">https://developers.google.com/google-apps/spreadsheets</a></p>
    </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/pages/diffpagesbyversion.action?pageId=55476961&revisedVersion=2&originalVersion=1">View Changes</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>