3
votes

I'm trying to implement authentication in my MVC 3 web application via Google Open Auth 2.0. I've already successfully formed URL request URL and it looks like this:

https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/userinfo.email+https://www.googleapis.com/auth/userinfo.profile&redirect_uri=http://localhost:1291/Account/Google/&response_type=token&client_id=MY_APP_ID.apps.googleusercontent.com

My expectation is to be redirected to the following URL:

http://localhost:1291/Account/Google?access_token=VALUE&token_type=VALUE&expires_in=VALUE

But actually I'm redirected here:

http://localhost:1291/Account/Google#access_token=VALUE&token_type=VALUE&expires_in=VALUE

The only difference is in "#" and "?" and without question mark I don't see query string parameters

2

2 Answers

1
votes

I tried to change the "response_type" from "token" to the "code" and the "#" symbol was successfully replaced with "?" and now I can extract the "code" from the query string. So, it was my fault. "response_type=token" is suggested to use with client js. More details here:

https://developers.google.com/accounts/docs/OAuth2Login (Javascript Responses section)

0
votes

I have a similar feature working in my application. The only difference I can see is the trailing / in your redirect_uri? Try:

redirect_uri=http://localhost:1291/Account/Google