skram
May 11th, 2011, 10:51 AM
Currently (M3) ConnectController's redirectToProviderConnect() method is private:
private String redirectToProviderConnect(String providerId) {
return "redirect:/connect/" + providerId;
}
The problem is we can't override or set a custom redirect URL. The default method implementation assumes that after the domain we have a URL with a request mapping to /connect/{providerId}.
For example, if my domain is http://mydomain.com and I'm trying to connect to Facebook, redirectToProvider() will redirect to http://mydomain.com/connect/facebook. This will work if you have a RequestMapping that matches such. However if in your web.xml you declared a different URL hierarchy for DispatcherServlet , then you'll run to HTTP status 404.
Assuming you have the following DispatcherServlet declaration:
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/myapp/*</url-pattern>
</servlet-mapping>
When you allow the app to have access to your Facebook account, it will redirect back to http://mydomain.com/connect/facebook which doesn't exist. The right path is http://mydomain.com/myapp/connect/facebook
This problem is similar to the following post http://forum.springsource.org/showthread.php?108826-Suggestion..-please-make-callbackUrl()-protected
private String redirectToProviderConnect(String providerId) {
return "redirect:/connect/" + providerId;
}
The problem is we can't override or set a custom redirect URL. The default method implementation assumes that after the domain we have a URL with a request mapping to /connect/{providerId}.
For example, if my domain is http://mydomain.com and I'm trying to connect to Facebook, redirectToProvider() will redirect to http://mydomain.com/connect/facebook. This will work if you have a RequestMapping that matches such. However if in your web.xml you declared a different URL hierarchy for DispatcherServlet , then you'll run to HTTP status 404.
Assuming you have the following DispatcherServlet declaration:
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/myapp/*</url-pattern>
</servlet-mapping>
When you allow the app to have access to your Facebook account, it will redirect back to http://mydomain.com/connect/facebook which doesn't exist. The right path is http://mydomain.com/myapp/connect/facebook
This problem is similar to the following post http://forum.springsource.org/showthread.php?108826-Suggestion..-please-make-callbackUrl()-protected