How to redirect to another page after Google Login?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I am using google login as my SSO but when i successfully login with Google it redirect me back to my login page how can i redirect it to my homepage after login using Google login?



        if (!string.IsNullOrEmpty(Request.QueryString["code"]))
{
string code = Request.QueryString["code"];
string json = GoogleConnect.Fetch("me", code);
GoogleProfile profile = new JavaScriptSerializer().Deserialize<GoogleProfile>(json);
Label1.Text = profile.Id;
Label2.Text = profile.DisplayName.ToString();
Label3.Text = profile.Emails.Find(email => email.Type == "account").Value;


Image1.ImageUrl = profile.Image.Url;
ImageButton1.Visible = false;
}
if (Request.QueryString["error"] == "access_denied")
{
ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('Access denied.')", true);
}
}

protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
GoogleConnect.Authorize("profile", "email");

}









share|improve this question

























  • don't you get the token in the query string, you can validate it and later redirect it to the home page

    – Anirudha Gupta
    Jan 3 at 5:11











  • i only got the refresh token. How do i get the access token?

    – Gilson Lim
    Jan 3 at 20:15











  • stackoverflow.com/a/41860759/713789

    – Anirudha Gupta
    Jan 3 at 20:20











  • which part of it shows the part of retrieving the access token? Sorry

    – Gilson Lim
    Jan 3 at 20:43











  • I don't have the code but I do the same thing 2 weeks ago, send the token and get the access token (which is expire in 3600 seconds = 1 hour)

    – Anirudha Gupta
    Jan 4 at 4:28


















0















I am using google login as my SSO but when i successfully login with Google it redirect me back to my login page how can i redirect it to my homepage after login using Google login?



        if (!string.IsNullOrEmpty(Request.QueryString["code"]))
{
string code = Request.QueryString["code"];
string json = GoogleConnect.Fetch("me", code);
GoogleProfile profile = new JavaScriptSerializer().Deserialize<GoogleProfile>(json);
Label1.Text = profile.Id;
Label2.Text = profile.DisplayName.ToString();
Label3.Text = profile.Emails.Find(email => email.Type == "account").Value;


Image1.ImageUrl = profile.Image.Url;
ImageButton1.Visible = false;
}
if (Request.QueryString["error"] == "access_denied")
{
ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('Access denied.')", true);
}
}

protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
GoogleConnect.Authorize("profile", "email");

}









share|improve this question

























  • don't you get the token in the query string, you can validate it and later redirect it to the home page

    – Anirudha Gupta
    Jan 3 at 5:11











  • i only got the refresh token. How do i get the access token?

    – Gilson Lim
    Jan 3 at 20:15











  • stackoverflow.com/a/41860759/713789

    – Anirudha Gupta
    Jan 3 at 20:20











  • which part of it shows the part of retrieving the access token? Sorry

    – Gilson Lim
    Jan 3 at 20:43











  • I don't have the code but I do the same thing 2 weeks ago, send the token and get the access token (which is expire in 3600 seconds = 1 hour)

    – Anirudha Gupta
    Jan 4 at 4:28














0












0








0








I am using google login as my SSO but when i successfully login with Google it redirect me back to my login page how can i redirect it to my homepage after login using Google login?



        if (!string.IsNullOrEmpty(Request.QueryString["code"]))
{
string code = Request.QueryString["code"];
string json = GoogleConnect.Fetch("me", code);
GoogleProfile profile = new JavaScriptSerializer().Deserialize<GoogleProfile>(json);
Label1.Text = profile.Id;
Label2.Text = profile.DisplayName.ToString();
Label3.Text = profile.Emails.Find(email => email.Type == "account").Value;


Image1.ImageUrl = profile.Image.Url;
ImageButton1.Visible = false;
}
if (Request.QueryString["error"] == "access_denied")
{
ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('Access denied.')", true);
}
}

protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
GoogleConnect.Authorize("profile", "email");

}









share|improve this question
















I am using google login as my SSO but when i successfully login with Google it redirect me back to my login page how can i redirect it to my homepage after login using Google login?



        if (!string.IsNullOrEmpty(Request.QueryString["code"]))
{
string code = Request.QueryString["code"];
string json = GoogleConnect.Fetch("me", code);
GoogleProfile profile = new JavaScriptSerializer().Deserialize<GoogleProfile>(json);
Label1.Text = profile.Id;
Label2.Text = profile.DisplayName.ToString();
Label3.Text = profile.Emails.Find(email => email.Type == "account").Value;


Image1.ImageUrl = profile.Image.Url;
ImageButton1.Visible = false;
}
if (Request.QueryString["error"] == "access_denied")
{
ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('Access denied.')", true);
}
}

protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
GoogleConnect.Authorize("profile", "email");

}






c# asp.net login google-login






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 3 at 20:31







Gilson Lim

















asked Jan 3 at 5:09









Gilson LimGilson Lim

11




11













  • don't you get the token in the query string, you can validate it and later redirect it to the home page

    – Anirudha Gupta
    Jan 3 at 5:11











  • i only got the refresh token. How do i get the access token?

    – Gilson Lim
    Jan 3 at 20:15











  • stackoverflow.com/a/41860759/713789

    – Anirudha Gupta
    Jan 3 at 20:20











  • which part of it shows the part of retrieving the access token? Sorry

    – Gilson Lim
    Jan 3 at 20:43











  • I don't have the code but I do the same thing 2 weeks ago, send the token and get the access token (which is expire in 3600 seconds = 1 hour)

    – Anirudha Gupta
    Jan 4 at 4:28



















  • don't you get the token in the query string, you can validate it and later redirect it to the home page

    – Anirudha Gupta
    Jan 3 at 5:11











  • i only got the refresh token. How do i get the access token?

    – Gilson Lim
    Jan 3 at 20:15











  • stackoverflow.com/a/41860759/713789

    – Anirudha Gupta
    Jan 3 at 20:20











  • which part of it shows the part of retrieving the access token? Sorry

    – Gilson Lim
    Jan 3 at 20:43











  • I don't have the code but I do the same thing 2 weeks ago, send the token and get the access token (which is expire in 3600 seconds = 1 hour)

    – Anirudha Gupta
    Jan 4 at 4:28

















don't you get the token in the query string, you can validate it and later redirect it to the home page

– Anirudha Gupta
Jan 3 at 5:11





don't you get the token in the query string, you can validate it and later redirect it to the home page

– Anirudha Gupta
Jan 3 at 5:11













i only got the refresh token. How do i get the access token?

– Gilson Lim
Jan 3 at 20:15





i only got the refresh token. How do i get the access token?

– Gilson Lim
Jan 3 at 20:15













stackoverflow.com/a/41860759/713789

– Anirudha Gupta
Jan 3 at 20:20





stackoverflow.com/a/41860759/713789

– Anirudha Gupta
Jan 3 at 20:20













which part of it shows the part of retrieving the access token? Sorry

– Gilson Lim
Jan 3 at 20:43





which part of it shows the part of retrieving the access token? Sorry

– Gilson Lim
Jan 3 at 20:43













I don't have the code but I do the same thing 2 weeks ago, send the token and get the access token (which is expire in 3600 seconds = 1 hour)

– Anirudha Gupta
Jan 4 at 4:28





I don't have the code but I do the same thing 2 weeks ago, send the token and get the access token (which is expire in 3600 seconds = 1 hour)

– Anirudha Gupta
Jan 4 at 4:28












2 Answers
2






active

oldest

votes


















0














you need to pass a callback url in google authentication api. After callback the provided url will called and method defined is this will be executed. In that method you will get user information and token to validate. After that you can redirect to your home page.






share|improve this answer































    0














    google callback give you success or error message. if you got success flag you get an array with user data. with those data you need to set an session. so you wont go back to your login page. or else when you call google api you haven't set proper call back for your application.






    share|improve this answer
























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54016655%2fhow-to-redirect-to-another-page-after-google-login%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      you need to pass a callback url in google authentication api. After callback the provided url will called and method defined is this will be executed. In that method you will get user information and token to validate. After that you can redirect to your home page.






      share|improve this answer




























        0














        you need to pass a callback url in google authentication api. After callback the provided url will called and method defined is this will be executed. In that method you will get user information and token to validate. After that you can redirect to your home page.






        share|improve this answer


























          0












          0








          0







          you need to pass a callback url in google authentication api. After callback the provided url will called and method defined is this will be executed. In that method you will get user information and token to validate. After that you can redirect to your home page.






          share|improve this answer













          you need to pass a callback url in google authentication api. After callback the provided url will called and method defined is this will be executed. In that method you will get user information and token to validate. After that you can redirect to your home page.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 3 at 5:19









          Yash ChhajerYash Chhajer

          111




          111

























              0














              google callback give you success or error message. if you got success flag you get an array with user data. with those data you need to set an session. so you wont go back to your login page. or else when you call google api you haven't set proper call back for your application.






              share|improve this answer




























                0














                google callback give you success or error message. if you got success flag you get an array with user data. with those data you need to set an session. so you wont go back to your login page. or else when you call google api you haven't set proper call back for your application.






                share|improve this answer


























                  0












                  0








                  0







                  google callback give you success or error message. if you got success flag you get an array with user data. with those data you need to set an session. so you wont go back to your login page. or else when you call google api you haven't set proper call back for your application.






                  share|improve this answer













                  google callback give you success or error message. if you got success flag you get an array with user data. with those data you need to set an session. so you wont go back to your login page. or else when you call google api you haven't set proper call back for your application.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jan 3 at 5:19









                  Masih AnsariMasih Ansari

                  3308




                  3308






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54016655%2fhow-to-redirect-to-another-page-after-google-login%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      MongoDB - Not Authorized To Execute Command

                      Npm cannot find a required file even through it is in the searched directory

                      in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith