google_sdk.js 1.2 KB

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