in plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/auth/DefaultAuthTokenService.java [44:78]
public CompletableFuture<GetSsoTokenResult> getSsoToken(final LoginType loginType, final LoginParams loginParams,
final boolean loginOnInvalidToken) {
GetSsoTokenParams getSsoTokenParams = createGetSsoTokenParams(loginType, loginOnInvalidToken);
return lspProvider.getAmazonQServer()
.thenApply(server -> {
if (loginOnInvalidToken && loginType.equals(LoginType.IAM_IDENTITY_CENTER)) {
var profile = new Profile();
profile.setName(Constants.IDC_PROFILE_NAME);
profile.setProfileKinds(Collections.singletonList(Constants.IDC_PROFILE_KIND));
profile.setProfileSettings(new ProfileSettings(loginParams.getLoginIdcParams().getRegion(), Constants.IDC_SESSION_NAME));
var ssoSession = new SsoSession();
ssoSession.setName(Constants.IDC_SESSION_NAME);
ssoSession.setSsoSessionSettings(new SsoSessionSettings(
loginParams.getLoginIdcParams().getUrl(),
loginParams.getLoginIdcParams().getRegion(),
Q_SCOPES)
);
var updateProfileOptions = new UpdateProfileOptions(true, true, true, false);
var updateProfileParams = new UpdateProfileParams(profile, ssoSession, updateProfileOptions);
try {
server.updateProfile(updateProfileParams).get();
} catch (Exception e) {
throw new AmazonQPluginException("Failed to update profile", e);
}
}
return server;
})
.thenCompose(server -> server.getSsoToken(getSsoTokenParams))
.thenApply(response -> {
return response;
})
.exceptionally(throwable -> {
throw new AmazonQPluginException("Failed to fetch SSO token", throwable);
});
}