I have a project on Google App Engine and an Android project. I need to do login on GAE using Android.
On GAE, I have this code: (redirect user to google login page, it's exactly I want!)
UserService userService = UserServiceFactory.getUserService();
String URL = request.getRequestURI();
if (request.getUserPrincipal() != null) {
// I need to send the MY_GENERATED_TOKEN to my android app
response.getWriter().println(MY_GENERATED_TOKEN);
} else {
response.sendRedirect(userService.createLoginURL(URL));
}
This code is default, and suggested by Google. My problem is that I don't know how access this on my Android app.
I have an Android activity, with a button. I want that when I click on button, open the android browser on Google's login page, I do login, the browser closes automatically and my app receives the token generated by GAE (it isn't a google token, it is a token generated by me).
I don't want to use endpoints.
If you really want to open it with the default browser here is my approach:
1. Open Login Page url
2. Login then redirect to an android handled intent-filter from your app
# example: http://your-caught-login-intent-filter.example.com or
# your-app-login://scheme
3. Pass along the token and you're set
But I suggest just use the webview, then you'll have more control:
1. Create a webview, then load the login url
2. Make sure to set the webviewClient onFinishPage
3. Lookup the resulting html for your token
http://developer.android.com/reference/android/webkit/WebView.html