I am using the Google UserService to get login and logout URLs for my app engine Angular application and am trying to pass the path for the redirect as a query param. This is an example of an Angular URL:
http://localhost:8080/#/dashboard
In Java I am trying to create the Url like this:
String logoutUrl = UserServiceFactory.getUserService().createLogoutURL(redirectPath);
redirectPath is the query param string "#/dashboard" as expected.
The problem is that the URL that is produced with the included '#' does not work. It just redirects to itself with a new URL. Here is a sample of what the URL looks like that is generated from the UserService:
/_ah/logout?continue=%23%2Fdashboard
If I just pass the string "/" to the endpoint then I get a URL like this:
/_ah/logout?continue=%2F
This works as expected and loads my Angular app at the root document. I would really like to be able to get my UserService URLS to work as expected. Any ideas?
This is the URL that it redirects to from the URL above:
http://localhost:8080/_ah/logout?continue=%23%2Fdashboard#/dashboard
I found a solution to the problem. The UserService works fine if I send the full URL instead of just the resource path. My Angular code now looks like the following. The app will get the login URL and then redirect to the requested URL upon login. This is actually in a service but I simplified the code for StackOverflow.
$http({
url: '/rest/user/login_uri?redirectPath=' + encodeURIComponent($location.absUrl()),
method: 'GET',
contentType: "application/json"
}).success(function (data) {
$window.location.href = data.uri;
}).catch(function (data) {
//Handle failed request....
});
I hope this helps somebody down the road.