我使用 MGWT 创建了一个 Web 应用程序,该应用程序使用 GWT-oauth2 登录 Google。
在标准 iOS Safari 中运行一切正常,但是当用户执行“添加到主屏幕”并重新启动没有地址和按钮栏的应用程序时,它不会在登录后从 Google 的登录窗口重定向回来。它只显示一个空白的白页。
我使用 Google API 控制台(访问)进行重定向:重定向 URI:http: //mobile.XXXXXXXX.com/appimpl/oauthWindow.html
任何帮助表示赞赏。卡尔
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());
}
});
}