mattjohnsonpint / DotNetOpenAuth.GoogleOAuth2

DotNetOpenAuth OAuth2 Client for Google
23 stars 18 forks source link

ReturnUrl Parameter Is Null After Redirect #3

Closed corydeppen closed 11 years ago

corydeppen commented 11 years ago

I'm not sure if it's safe to assume that many folks will be integrating this library into MVC projects that contain an AccountsController from the default MVC template, but I noticed that the returnUrl parameter of the ExternalLoginCallback method is null after the redirect. Since the returnUrl parameter is actually inside the state parameter that Google passes back, I had to add the following snippet:

GoogleOAuth2Client.RewriteRequest();

// Pull the returnUrl from the rewritten request,
// since it was originally packed in the state parameter.
var url = Request.QueryString["ReturnUrl"];
if (string.IsNullOrEmpty(returnUrl) && url != null)
{
    returnUrl = url;
}

OAuthWebSecurity.VerifyAuthentication(....)

This may be something others find useful and might be helpful to include in the Usage section of the readme.

mattjohnsonpint commented 11 years ago

Good point. The docs should clarify that anything packed into the state parameter are now found directly on the querystring.

mattjohnsonpint commented 11 years ago

Updated the readme. And thanks!