diff --git a/sdk/core/azure-core/inc/credentials/credentials.hpp b/sdk/core/azure-core/inc/credentials/credentials.hpp index 253667de8..d5da90286 100644 --- a/sdk/core/azure-core/inc/credentials/credentials.hpp +++ b/sdk/core/azure-core/inc/credentials/credentials.hpp @@ -34,17 +34,21 @@ namespace Azure { namespace Core { namespace Credentials { class ClientSecretCredential : public TokenCredential { private: + static std::string const g_aadGlobalAuthority; + std::string const m_tenantId; std::string const m_clientId; std::string const m_clientSecret; + std::string const m_authority; public: explicit ClientSecretCredential( std::string tenantId, std::string clientId, - std::string clientSecret) + std::string clientSecret, + std::string authority = g_aadGlobalAuthority) : m_tenantId(std::move(tenantId)), m_clientId(std::move(clientId)), - m_clientSecret(std::move(clientSecret)) + m_clientSecret(std::move(clientSecret)), m_authority(std::move(authority)) { } diff --git a/sdk/core/azure-core/src/credentials/credentials.cpp b/sdk/core/azure-core/src/credentials/credentials.cpp index 4b5351e14..17611b2c8 100644 --- a/sdk/core/azure-core/src/credentials/credentials.cpp +++ b/sdk/core/azure-core/src/credentials/credentials.cpp @@ -37,7 +37,10 @@ std::string UrlEncode(std::string const& s) } } // namespace -AccessToken ClientSecretCredential::GetToken( +std::string const Azure::Core::Credentials::ClientSecretCredential::g_aadGlobalAuthority + = "https://login.microsoftonline.com/"; + +AccessToken Azure::Core::Credentials::ClientSecretCredential::GetToken( Context const& context, std::vector const& scopes) const { @@ -45,7 +48,7 @@ AccessToken ClientSecretCredential::GetToken( try { std::ostringstream url; - url << "https://login.microsoftonline.com/" << UrlEncode(m_tenantId) << "/oauth2/v2.0/token"; + url << m_authority << UrlEncode(m_tenantId) << "/oauth2/v2.0/token"; std::ostringstream body; body << "grant_type=client_credentials&client_id=" << UrlEncode(m_clientId)