asp.net - Why google login redirect back to site with hashtag - can it be avoided -
i didn't succeeded find relevant reply must inquire :) implemented google plus login site. few workarounds work fine but... when redirected site google returned next url:
http://localhost/mysite/west/default.aspx#state=/profile&access_token=ya29.qqdrtcvtgoebs86bg10pufg3dksjz74blregulhldljw2o5qq6g7ilf17zqsm8imlg0c82pqyp2z-g&token_type=bearer&expires_in=3600
because of parameter here #state=/profile&
first have read url in javascript on load, remove part prepare url , this:
var url = "default.aspx?" + querystring; window.location = url;
and can go on read query string in code. don't because when create 2 postback on page , want avoid if possible. redirect url must have or can avoided? redirect 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="+this.return_url+"&response_type=token&client_id=" + this.client_id; response.redirect(url);
when site:
if (this.request.querystring["access_token"] != null) { string uri = "https://www.googleapis.com/oauth2/v1/userinfo?access_token=" + request.querystring["access_token"].tostring(); webclient webclient = new webclient(); stream stream = webclient.openread(uri);
change response_type=token
response_type=code
. callback url have code
query parameter accessible server side instead of fragment. have implement step 4 exchange code access_token.
asp.net oauth google-plus google-oauth google-login
No comments:
Post a Comment