Search in sources :

Example 1 with RSConnectAuthUser

use of org.rstudio.studio.client.rsconnect.model.RSConnectAuthUser in project rstudio by rstudio.

the class RSAccountConnector method connectLocalAccount.

private void connectLocalAccount(final NewRSConnectAccountResult result, final ProgressIndicator indicator, final OperationWithInput<AccountConnectResult> onConnected) {
    indicator.onProgress("Adding account...");
    final RSConnectAuthUser user = result.getAuthUser();
    final RSConnectServerInfo serverInfo = result.getServerInfo();
    final RSConnectPreAuthToken token = result.getPreAuthToken();
    server_.registerUserToken(serverInfo.getName(), result.getAccountNickname(), user.getId(), token, new ServerRequestCallback<Void>() {

        @Override
        public void onResponseReceived(Void result) {
            onConnected.execute(AccountConnectResult.Successful);
        }

        @Override
        public void onError(ServerError error) {
            display_.showErrorMessage("Account Connect Failed", "Your account was authenticated successfully, but could " + "not be connected to RStudio. Make sure your installation " + "of the 'rsconnect' package is correct for the server " + "you're connecting to.\n\n" + serverInfo.getInfoString() + "\n" + error.getMessage());
            onConnected.execute(AccountConnectResult.Failed);
        }
    });
}
Also used : RSConnectAuthUser(org.rstudio.studio.client.rsconnect.model.RSConnectAuthUser) ServerError(org.rstudio.studio.client.server.ServerError) RSConnectPreAuthToken(org.rstudio.studio.client.rsconnect.model.RSConnectPreAuthToken) Void(org.rstudio.studio.client.server.Void) RSConnectServerInfo(org.rstudio.studio.client.rsconnect.model.RSConnectServerInfo)

Example 2 with RSConnectAuthUser

use of org.rstudio.studio.client.rsconnect.model.RSConnectAuthUser in project rstudio by rstudio.

the class NewRSConnectAuthPage method pollForAuthCompleted.

private void pollForAuthCompleted() {
    Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {

        @Override
        public boolean execute() {
            // don't keep polling once auth is complete or window is closed
            if (!waitingForAuth_.getValue())
                return false;
            // returned for some reason, just wait for it to finish
            if (runningAuthCompleteCheck_)
                return true;
            runningAuthCompleteCheck_ = true;
            server_.getUserFromToken(result_.getServerInfo().getUrl(), result_.getPreAuthToken(), new ServerRequestCallback<RSConnectAuthUser>() {

                @Override
                public void onResponseReceived(RSConnectAuthUser user) {
                    runningAuthCompleteCheck_ = false;
                    // just wait and try again
                    if (!user.isValidUser())
                        return;
                    // user is valid--cache account info and close the
                    // window
                    result_.setAuthUser(user);
                    waitingForAuth_.setValue(false, true);
                    if (Desktop.isDesktop()) {
                        // on the desktop, we can close the window by name
                        Desktop.getFrame().closeNamedWindow(AUTH_WINDOW_NAME);
                    }
                    onUserAuthVerified();
                }

                @Override
                public void onError(ServerError error) {
                    // ignore this error
                    runningAuthCompleteCheck_ = false;
                }
            });
            return true;
        }
    }, 1000);
}
Also used : RSConnectAuthUser(org.rstudio.studio.client.rsconnect.model.RSConnectAuthUser) ServerError(org.rstudio.studio.client.server.ServerError) RepeatingCommand(com.google.gwt.core.client.Scheduler.RepeatingCommand) ServerRequestCallback(org.rstudio.studio.client.server.ServerRequestCallback)

Aggregations

RSConnectAuthUser (org.rstudio.studio.client.rsconnect.model.RSConnectAuthUser)2 ServerError (org.rstudio.studio.client.server.ServerError)2 RepeatingCommand (com.google.gwt.core.client.Scheduler.RepeatingCommand)1 RSConnectPreAuthToken (org.rstudio.studio.client.rsconnect.model.RSConnectPreAuthToken)1 RSConnectServerInfo (org.rstudio.studio.client.rsconnect.model.RSConnectServerInfo)1 ServerRequestCallback (org.rstudio.studio.client.server.ServerRequestCallback)1 Void (org.rstudio.studio.client.server.Void)1