I’m not able to fetch the access_token value from a QueryString in ASP.Net (C#).
Google is sending the authorization token, but I am not able to capture the token value by using
- QueryString (getting null)
- splitting string (not getting full url)
The RedirectUrl is: http://www.onfrnz.com/auth.aspx
http://www.onfrnz.com/auth.aspx#state=/profile
&access_token={ACCESS_TOKEN}
&token_type=Bearer
&expires_in=3600
Please help me on this. I don’t want to use a library. Thanks in advance.
You’re trying to access a hash fragment value in server-side code. The hash fragment value (after the # in the URL), does not get sent from the web browser to the web server, and thus will not be accessible in server-side code.
When you initially kick off the OAuth flow, you’re likely using:
This indicates you want to use the flow for client-side (JavaScript) applications (called the “implicit” flow in the spec).
Instead, you should be using:
This will return an authorization
codevalue in the query parameter, which you should be able to retrieve using your .NET code, and then exchange for an access token by making a server-to-server request to Google.More information on Google’s OAuth 2.0 flow for web server applications (authorization code flow) is available here:
https://developers.google.com/accounts/docs/OAuth2WebServer