0

I have the following code to authenticate a user via the Google+ signin button:

<html>
<head>
<!-- google api -->
<meta name="google-signin-client_id" content="xxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com">
<meta name="google-signin-scope" content="email">
</head>
<body>
  <div id="google-signin"></div>
  <script>

  function signOut() {
      var auth2 = gapi.auth2.getAuthInstance();
      auth2.signOut().then(function () {
          console.log('User signed out.');
      });


  function onGoogleSuccess(googleUser) {

      // get the token
      var id_token = googleUser.getAuthResponse().id_token;
     // console.log('Logged in as: ' + googleUser.getBasicProfile().getName());
   }

  function onGoogleFailure(error) {
  console.log(error);
  }

function renderButton() {
    gapi.signin2.render('google-signin', {
    'scope': 'https://www.googleapis.com/auth/plus.login',
    'width': 242,
    'height': 56,
    'longtitle': true,
    'theme': 'dark',
    'onsuccess': onGoogleSuccess,
    'onfailure': onGoogleFailure
  });
}
</script>
</body>
</html>

When I click the button, an authentication popup windows appear, and once I authorize it, the function 'onGooglesuccess' runs, but it doesn't redirect to a page. I want it to redirect to a specific .aspx page where I can grab the code, replace it with a tokrn and grab user info.

How can I do that? I tried reading the docs on Google, but I just can't figure how to do it.

I'm developing my application in ASP.NET 4.5 / C# / Javascipt

Liron Harel
  • 10,819
  • 26
  • 118
  • 217
  • 2
    If you're doing this entirely from javascript and your `onSuccess` handler is called, it's not up to Google+ to redirect. Is your question then "how to redirect from javascript in asp.net"? If so, *that* question already has an answer [here](http://stackoverflow.com/questions/503093/how-can-i-make-a-redirect-page-using-jquery) – ardila Jan 19 '16 at 17:47
  • @ardila I thought it works like Facebook, where you tell it where to redirect via the URL. I thought that Google takes that redirect from the settings. Thanks for clarifying this. – Liron Harel Jan 19 '16 at 17:49

0 Answers0