$(document).ready(function() { var is_signup = (window.location.href.indexOf('signup') >= 0 ? 1 : 0); logInWithFacebook = function() { FB.login(function(response) { if (response.authResponse) { window.location.href = '/social_auth/social/fb_callback?is_signup=' + is_signup; // Now you can redirect the user or do an AJAX request to // a PHP script that grabs the signed request from the cookie. } }, {scope: 'email'}); return false; }; window.fbAsyncInit = function() { FB.init({ appId: 131609020781244, cookie: true, version: 'v2.5' }); }; (function(d, s, id){ var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) {return;} js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/sdk.js"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); // gapi.load('auth2', function(){ // // Retrieve the singleton for the GoogleAuth library and set up the client. // auth2 = gapi.auth2.init({ // client_id: '626510304248-kp0j23erdpi9eu62e3lsk3rq0khbgaj1.apps.googleusercontent.com', // cookiepolicy: 'single_host_origin', // fetch_basic_profile: true // }); // if(typeof androidAppProxy !== "undefined"){ // $("#login_google").on('click', function() { // androidAppProxy.showGoogleLogin(); // }); // } else { // attachSignin(document.getElementById('login_google')); // } // }); function attachSignin(element) { auth2.attachClickHandler(element, {}, function(googleUser) { console.log(googleUser); var response = googleUser.getAuthResponse(true); window.location.href = '/social_auth/social/google_callback?token=' + response.access_token + '&id_token=' + response.id_token+'&is_signup=' + is_signup; }, function(error) { }); } });