1

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());
        }
    });
}
Carl
  • 147
  • 1
  • 7
  • can you post the relevant code? – Daniel Kurka Sep 09 '12 at 18:29
  • Added relevant code in original post. MGWT looks very promising. I hope I can make it over this little hurdle. – Carl Sep 10 '12 at 09:34
  • I think I know what is going on. MGWT.applySettings(MGWTSettings.getAppSetting()) probably sets the and when the app is launched in full screen mode you can no longer use the url (since it's not there) to send back the token to the client. Use instead: settings = new MGWTSettings(); settings.setFullscreen(false); settings.setPreventScrolling(false); This doesn't give you a full screen in standalone mode but it works. – Carl Sep 12 '12 at 07:13

1 Answers1

0

We just stumbled upon a similar, possibly exactly the same issue with GWT. GWT does not recognize the browser at all in full screen (mobile web app) mode as Safari and fails to load the proper permutation (it tries to load the 'undefined' permutation). We suspect this may have something to do with the user agent being different in that mode. See:

ipad user agent changes during use?

and

Which browser have this strange user agent? (IOS device)

Community
  • 1
  • 1
Learner
  • 1,215
  • 1
  • 11
  • 26