public string Run(DateTime startInstant) { this.Init(); environment.awsRoleToAssume = currentProfile.RoleArn; if (currentSession.IsPresent() && sessionHelper.SessionIsActive(startInstant, currentSession) && string.IsNullOrWhiteSpace(environment.oktaProfile)) { return(currentSession.ProfileName); } var samlResponse = oktaSaml.GetSamlResponse(); AssumeRoleWithSAMLRequest assumeRequest = roleHelper.ChooseAwsRoleToAssume(samlResponse); DateTime sessionExpiry = startInstant.AddSeconds(assumeRequest.DurationSeconds - 30); AssumeRoleWithSAMLResult assumeResult = roleHelper.AssumeChosenAwsRole(assumeRequest); String profileName = profileHelper.CreateAwsProfile(assumeResult); environment.oktaProfile = profileName; environment.awsRoleToAssume = assumeRequest.RoleArn; configHelper.UpdateConfigFile(); sessionHelper.AddOrUpdateProfile(sessionExpiry); sessionHelper.UpdateCurrentSession(sessionExpiry, profileName); return(profileName); }