@@ -27,24 +27,18 @@ static const char SSO_GRANT_TYPE[] = "refresh_token";
27
27
const size_t SSOBearerTokenProvider::REFRESH_WINDOW_BEFORE_EXPIRATION_S = 600 ;
28
28
const size_t SSOBearerTokenProvider::REFRESH_ATTEMPT_INTERVAL_S = 30 ;
29
29
30
- SSOBearerTokenProvider::SSOBearerTokenProvider ()
31
- : m_profileToUse(Aws::Auth::GetConfigProfileName()),
32
- m_lastUpdateAttempt((int64_t ) 0)
30
+ SSOBearerTokenProvider::SSOBearerTokenProvider () : SSOBearerTokenProvider(Aws::Auth::GetConfigProfileName(), nullptr)
33
31
{
34
- AWS_LOGSTREAM_INFO (SSO_BEARER_TOKEN_PROVIDER_LOG_TAG, " Setting sso bearerToken provider to read config from " << m_profileToUse);
35
32
}
36
33
37
- SSOBearerTokenProvider::SSOBearerTokenProvider (const Aws::String& awsProfile)
38
- : m_profileToUse(awsProfile),
39
- m_lastUpdateAttempt((int64_t ) 0)
34
+ SSOBearerTokenProvider::SSOBearerTokenProvider (const Aws::String& awsProfile) : SSOBearerTokenProvider(awsProfile, nullptr )
40
35
{
41
- AWS_LOGSTREAM_INFO (SSO_BEARER_TOKEN_PROVIDER_LOG_TAG, " Setting sso bearerToken provider to read config from " << m_profileToUse);
42
36
}
43
37
44
38
SSOBearerTokenProvider::SSOBearerTokenProvider (const Aws::String& awsProfile, std::shared_ptr<const Client::ClientConfiguration> config)
45
39
: m_profileToUse(awsProfile),
46
- m_lastUpdateAttempt(( int64_t )0 ),
47
- m_config(config )
40
+ m_config(config ? std::move(config) : Aws::MakeShared<Client::ClientConfiguration>(SSO_BEARER_TOKEN_PROVIDER_LOG_TAG) ),
41
+ m_lastUpdateAttempt(( int64_t )0 )
48
42
{
49
43
AWS_LOGSTREAM_INFO (SSO_BEARER_TOKEN_PROVIDER_LOG_TAG, " Setting sso bearerToken provider to read config from " << m_profileToUse);
50
44
}
@@ -105,16 +99,10 @@ void SSOBearerTokenProvider::RefreshFromSso()
105
99
/* The SSO token provider must not resolve if any SSO configuration values are present directly on the profile
106
100
* instead of an `sso-session` section. The SSO token provider must ignore these configuration values if these
107
101
* values are present directly on the profile instead of an `sso-session` section. */
108
- // config. region = m_profile.GetSsoRegion(); // <- intentionally not used per comment above
102
+ // auto& region = m_profile.GetSsoRegion(); // <- intentionally not used per comment above
109
103
auto & region = cachedSsoToken.region ;
110
- Aws::Client::ClientConfiguration defaultConfig;
111
- if (!m_config)
112
- {
113
- defaultConfig.scheme = scheme;
114
- defaultConfig.region = region;
115
- }
116
- const Aws::Client::ClientConfiguration& config = m_config ? *m_config : defaultConfig;
117
- m_client = Aws::MakeUnique<Aws::Internal::SSOCredentialsClient>(SSO_BEARER_TOKEN_PROVIDER_LOG_TAG, config, scheme, cachedSsoToken.region );
104
+ // m_config->region might not be the same as the SSO region, but the former is not used by the SSO client.
105
+ m_client = Aws::MakeUnique<Aws::Internal::SSOCredentialsClient>(SSO_BEARER_TOKEN_PROVIDER_LOG_TAG, *m_config, scheme, region);
118
106
}
119
107
120
108
Aws::Internal::SSOCredentialsClient::SSOCreateTokenRequest ssoCreateTokenRequest;
0 commit comments