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);
}
});
}
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);
}
Aggregations