@@ -184,19 +184,26 @@ public static Task<string> GetAccessToken(
184184
185185 if ( string . IsNullOrEmpty ( clientId ) )
186186 {
187- throw new ArgumentException ( nameof ( accessTokenUri ) ) ;
187+ throw new ArgumentException ( nameof ( clientId ) ) ;
188188 }
189189
190190 if ( string . IsNullOrEmpty ( clientSecret ) )
191191 {
192- throw new ArgumentException ( nameof ( accessTokenUri ) ) ;
192+ throw new ArgumentException ( nameof ( clientSecret ) ) ;
193193 }
194194
195- return GetAccessTokenInternal ( accessTokenUri , clientId , clientSecret , timeout , validateCertificates , logger ) ;
195+ var parsedUri = new Uri ( accessTokenUri ) ;
196+
197+ if ( ! parsedUri . IsWellFormedOriginalString ( ) )
198+ {
199+ throw new ArgumentException ( "Access token Uri is not well formed" , nameof ( accessTokenUri ) ) ;
200+ }
201+
202+ return GetAccessTokenInternal ( parsedUri , clientId , clientSecret , timeout , validateCertificates , logger ) ;
196203 }
197204
198205 private static async Task < string > GetAccessTokenInternal (
199- string accessTokenUri ,
206+ Uri accessTokenUri ,
200207 string clientId ,
201208 string clientSecret ,
202209 int timeout ,
@@ -228,7 +235,7 @@ private static async Task<string> GetAccessTokenInternal(
228235 logger ? . LogInformation (
229236 "GetAccessToken returned status: {0} while obtaining access token from: {1}" ,
230237 response . StatusCode ,
231- accessTokenUri ) ;
238+ WebUtility . UrlEncode ( accessTokenUri . OriginalString ) ) ;
232239 return null ;
233240 }
234241
@@ -240,7 +247,7 @@ private static async Task<string> GetAccessTokenInternal(
240247 }
241248 catch ( Exception e )
242249 {
243- logger ? . LogError ( "GetAccessToken exception: {0} , obtaining access token from: {1}" , e , WebUtility . UrlEncode ( accessTokenUri ) ) ;
250+ logger ? . LogError ( "GetAccessToken exception: {0}, obtaining access token from: {1}" , e , WebUtility . UrlEncode ( accessTokenUri . OriginalString ) ) ;
244251 }
245252 finally
246253 {
0 commit comments