Note that there are some explanatory texts on larger screens.

plurals
  1. POFusionTables private table with OAUTH2
    text
    copied!<p>Good pic by <a href="http://cloudspace.com/blog/2009/02/10/oauth-followup/#.Vd2zZ_ntlBd" rel="nofollow noreferrer">Tim Rosenberg</a> that shows exactly how OAUTH2 work's:</p> <p><a href="https://i.stack.imgur.com/hLH9R.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hLH9R.jpg" alt="enter image description here"></a></p> <p>I'm kind a lazy to even start looking on this <a href="http://oauth.googlecode.com/svn/code/javascript/oauth.js" rel="nofollow noreferrer">2</a> <a href="http://oauth.googlecode.com/svn/code/javascript/sha1.js" rel="nofollow noreferrer">files</a> and <a href="http://oauth.googlecode.com/svn/code/javascript/oauthTest.js" rel="nofollow noreferrer">test</a> so I searched for easyest way to</p> <p>1.get token</p> <p>2.access with that token</p> <p>with help of <a href="http://code.google.com/p/gwt-oauth2/source/browse/trunk/samples/script/gwt-oauth2.js" rel="nofollow noreferrer">gwt-oauth2</a></p> <p>put it into index.php head : <code>&lt;script type="text/javascript" src="gwt-oauth2.js"&gt;&lt;/script&gt;</code></p> <p>and this in body</p> <pre><code>&lt;script type="text/javascript"&gt; (function() { var GOOGLE_AUTH_URL = "https://accounts.google.com/o/oauth2/auth"; var GOOGLE_CLIENT_ID = "CLIENT_ID"; //var PLUS_ME_SCOPE = "https://www.googleapis.com/auth/plus.me"; //var FusionTable_SCOPE = "https://www.googleapis.com/auth/fusiontables"; var button = document.createElement("button"); button.innerText = "Authenticate with Google"; button.onclick = function() { var req = { 'authUrl' : GOOGLE_AUTH_URL, 'clientId' : GOOGLE_CLIENT_ID, 'scopes': ['https://www.googleapis.com/auth/plus.me', 'https://www.googleapis.com/auth/fusiontables' ], }; oauth2.login(req, function(token) { alert('Got an OAuth token:\n'+ token +'\n'+ 'Token expires in '+ oauth2.expiresIn(req) +' ms\n'); }, function(error) { alert("Error:\n" + error); }); }; var dv = document.getElementById('admin-content'); dv.appendChild(button); var clearTokens = document.createElement('button'); clearTokens.innerText = 'Clear all tokens' clearTokens.onclick = oauth2.clearAllTokens; dv.appendChild(clearTokens); })(); &lt;/script&gt; </code></pre> <p>OK, </p> <p>Now you can see connection and redirection to oauthWindow.html in new window without errors. GET parameters now showing you <code>access_token</code> <code>token_type</code> <code>expires_in</code>. Check the access_token <a href="http://ft2json.appspot.com/api/samples.html" rel="nofollow noreferrer">HERE</a></p> <p>As you see access_token working great BUT</p> <p>What you still don't get is first alert from that :</p> <pre><code>oauth2.login(req, function(token) { alert('Got an OAuth token:\n' + token + '\n' + 'Token expires in ' + oauth2.expiresIn(req) + ' ms\n'); }, function(error) { alert("Error:\n" + error); }); </code></pre> <p>Second alert works fine and when you try to Auth. again if oauthWindow.html still open it shows you an error alert(so it's working!) Now let's add that little code to oauthWindow.html</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;script type="text/javascript"&gt; if (window.opener &amp;&amp; window.opener.oauth2 &amp;&amp; window.opener.oauth2.__doLogin) { window.opener.oauth2.__doLogin(location.hash); } else { document.body.innerText = "Your browser seems to be stopping this window from communicating with the main window."; } &lt;/script&gt; &lt;/head&gt; &lt;body&gt;&lt;/body&gt; &lt;/html&gt; </code></pre> <p>Perfect!</p> <p>Now if you want to work with private tables all you need is to add an access_token to url. </p> <p>Thanks for giving me the reason to answer myself!</p>
 

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