google_sdk.js 1.0 KB

12345678910111213141516171819202122232425
  1. function plusoneCallback(auth){
  2. if (!auth['g-oauth-window']) { console.log('skip autologin'); }
  3. else if(auth['access_token']) {
  4. gapi.client.load('oauth2', 'v2', function(){
  5. gapi.client.oauth2.userinfo.get().execute(function(oauthResp){
  6. if(plusLogin) {console.log(JSON.stringify(oauthResp)); plusLogin(oauthResp); }
  7. }); });
  8. } else if(auth['error']) { console.log('error'); }
  9. }
  10. function render(){
  11. gapi.signin.render('pluslogin', {
  12. 'callback':'plusoneCallback',
  13. 'clientid':'146782506820.apps.googleusercontent.com',
  14. 'cookiepolicy': 'http://synrc.com',
  15. 'requestvisibleactions':'http://schemas.google.com/AddActivity',
  16. 'scope':'https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/userinfo.email '
  17. });
  18. }
  19. (function() {
  20. var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
  21. po.src = 'https://apis.google.com/js/client:plusone.js?parsetags=explicit&onload=render';
  22. var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
  23. })();