@@ -28,15 +28,29 @@ using Aws::Utils::Threading::ReaderLockGuard;
28
28
29
29
static const char SSO_CREDENTIALS_PROVIDER_LOG_TAG[] = " SSOCredentialsProvider" ;
30
30
31
- SSOCredentialsProvider::SSOCredentialsProvider () : m_profileToUse (GetConfigProfileName())
31
+ SSOCredentialsProvider::SSOCredentialsProvider () : SSOCredentialsProvider (GetConfigProfileName(), nullptr )
32
32
{
33
- AWS_LOGSTREAM_INFO (SSO_CREDENTIALS_PROVIDER_LOG_TAG, " Setting sso credentials provider to read config from " << m_profileToUse);
34
33
}
35
34
36
- SSOCredentialsProvider::SSOCredentialsProvider (const Aws::String& profile) : m_profileToUse(profile),
37
- m_bearerTokenProvider(profile)
35
+ SSOCredentialsProvider::SSOCredentialsProvider (const Aws::String& profile) : SSOCredentialsProvider(profile, nullptr )
38
36
{
39
- AWS_LOGSTREAM_INFO (SSO_CREDENTIALS_PROVIDER_LOG_TAG, " Setting sso credentials provider to read config from " << m_profileToUse);
37
+ }
38
+
39
+ SSOCredentialsProvider::SSOCredentialsProvider (const Aws::String& profile, std::shared_ptr<const Aws::Client::ClientConfiguration> config) :
40
+ m_profileToUse(profile),
41
+ m_bearerTokenProvider(profile),
42
+ m_config(std::move(config))
43
+ {
44
+ AWS_LOGSTREAM_INFO (SSO_CREDENTIALS_PROVIDER_LOG_TAG, " Setting sso credentials provider to read config from " << m_profileToUse);
45
+ if (!m_config)
46
+ {
47
+ auto defaultConfig = Aws::MakeShared<Client::ClientConfiguration>(SSO_CREDENTIALS_PROVIDER_LOG_TAG);
48
+ defaultConfig->scheme = Aws::Http::Scheme::HTTPS;
49
+ // We cannot set region to m_ssoRegion because it is not yet known at this point. But it's not obtained from the client config either way.
50
+ Aws::Vector<Aws::String> retryableErrors{ " TooManyRequestsException" };
51
+ defaultConfig->retryStrategy = Aws::MakeShared<SpecifiedRetryableErrorsRetryStrategy>(SSO_CREDENTIALS_PROVIDER_LOG_TAG, std::move (retryableErrors), 3 /* maxRetries*/ );
52
+ m_config = std::move (defaultConfig);
53
+ }
40
54
}
41
55
42
56
AWSCredentials SSOCredentialsProvider::GetAWSCredentials ()
@@ -80,16 +94,7 @@ void SSOCredentialsProvider::Reload()
80
94
request.m_ssoRoleName = profile.GetSsoRoleName ();
81
95
request.m_accessToken = accessToken;
82
96
83
- Aws::Client::ClientConfiguration config;
84
- config.scheme = Aws::Http::Scheme::HTTPS;
85
- config.region = m_ssoRegion;
86
- AWS_LOGSTREAM_DEBUG (SSO_CREDENTIALS_PROVIDER_LOG_TAG, " Passing config to client for region: " << m_ssoRegion);
87
-
88
- Aws::Vector<Aws::String> retryableErrors;
89
- retryableErrors.push_back (" TooManyRequestsException" );
90
-
91
- config.retryStrategy = Aws::MakeShared<SpecifiedRetryableErrorsRetryStrategy>(SSO_CREDENTIALS_PROVIDER_LOG_TAG, retryableErrors, 3 /* maxRetries*/ );
92
- m_client = Aws::MakeUnique<Aws::Internal::SSOCredentialsClient>(SSO_CREDENTIALS_PROVIDER_LOG_TAG, config);
97
+ m_client = Aws::MakeUnique<Aws::Internal::SSOCredentialsClient>(SSO_CREDENTIALS_PROVIDER_LOG_TAG, *m_config, Aws::Http::Scheme::HTTPS, m_ssoRegion);
93
98
94
99
AWS_LOGSTREAM_TRACE (SSO_CREDENTIALS_PROVIDER_LOG_TAG, " Requesting credentials with AWS_ACCESS_KEY: " << m_ssoAccountId);
95
100
auto result = m_client->GetSSOCredentials (request);
0 commit comments