I have created a web app using MGWT that uses GWT-oauth2 to login at Google.
Everything works fine running in standard iOS Safari but when a user does a "Add to Home Screen" and relaunches the app without the address and buttons bars a it won't redirect back from Google's login window after login. It only shows is a blank, white page.
I use Google API Console (Access) for the redirect: Redirect URIs: http://mobile.XXXXXXXX.com/appimpl/oauthWindow.html
Any help is appreciated. Carl
public void onModuleLoad() {
MGWT.applySettings(MGWTSettings.getAppSetting());
login();
}
public static void login(){
final LoginServiceAsync scheduleService = GWT.create(LoginService.class);
String AUTH_URL = "https://accounts.google.com/o/oauth2/auth";
String CLIENT_ID = "XXXXXXXXXXX.apps.googleusercontent.com"; // available from the APIs console
String DOCS_SCOPE = "https://docs.google.com/feeds/";
String USER_SCOPE = "https://www.googleapis.com/auth/userinfo.email";
String PROFILE_SCOPE = "https://www.googleapis.com/auth/userinfo.profile";
AuthRequest req = new AuthRequest(AUTH_URL, CLIENT_ID)
.withScopes(DOCS_SCOPE, USER_SCOPE, PROFILE_SCOPE); // Can specify multiple scopes here
Auth.get().login(req, new Callback<String, Throwable>() {
@Override
public void onSuccess(final String token) {
Log.info("LoginImpl Login Success");
String url = "https://www.googleapis.com/oauth2/v1/userinfo?alt=json&access_token="+token+"&callback=";
JSONRequest.get(url, new JSONRequestHandler() {
@Override
public void onRequestComplete(JavaScriptObject json) {
Log.info("onRequestComplete()");
JSONObject obj = new JSONObject(json);
JSONValue emailValue = obj.get("email");
String email = emailValue.toString();
email = email.replace('"', ' ');
scheduleService.logInGoogle(token, email, new AsyncCallback<Void>() {
@Override
public void onFailure(Throwable error) {
Log.info("loginGoogleFail");
}
@Override
public void onSuccess(Void loginURL) {
System.out.println("GWT.getHostPageBaseURL() "+GWT.getHostPageBaseURL());
String baseURL = GWT.getHostPageBaseURL().replace("login", LoginImpl.path);
if(!GWT.isProdMode()){
baseURL += localCodesvr;
}
Log.info("logInGoogle success baseURL "+baseURL);
Window.Location.replace(baseURL);
}
});
}
});
}
@Override
public void onFailure(Throwable throwable) {
Log.info("Login Failure "+throwable.getLocalizedMessage());
}
});
}