asp.net - Why google login redirect back to site with hashtag - can it be avoided -


I have not been able to find any relevant answers for this, so I should ask :)
I used Google Plus Login to my site It works fine with some workings but
When I get redirected back to my site from Google, I come back to the following URL:

 < Code> http: // localhost / mysite /west/Default.aspx#state=/profile&access_token=ya29.qQDrtcVtgOEbS86Bg10puFG3dksJz74BlrEGulHldlJW2o5qQ6g7ilF17zQsm8iMLG0C82PQyp2Z-g&token_type=Bearer&expires_in=3600  

Due to this parameter here # state = / profile & amp; I have to read the URL in the first load on JavaScript,
remove this part to fix the URL and then do this:

  var url = "Default.aspx?" + Query string; Window.location = url;  

And then I can continue reading the code string normally in the code.
I do not like it because when I do this I postback my post on page 2 and if possible,
Should this be redirected to URL or be avoided?

Redirect to google:

  string = url = "https://accounts.google.com/o/oauth2/auth?scope=https://www Googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email&state=%2Fprofile&redirect_uri="+is.Return_url+"&response_type=token&client_id= "+ This CLIENT ID; Response.Redirect (URL);  

When I return to my site:

  if (this.Request.QueryString ["access_token"] = null) {string URI = "Https://www.googleapis.com/oauth2/v1/userinfo?access_token=" + Request .QueryString ["access_token"]. ToString (); Web client webclient = new webclient (); Stream stream = webClient.OpenRead (URI);    

Change response_type = token to response_type = code . The callback URL has a code query parameter that is accessible server side rather than one piece. Then you have to implement the code for access_token to exchange code.


Comments