@@ -82,7 +82,7 @@ public async Task<string> GetTokenAsync(string tokenType, bool forceRefetch, Can
8282 {
8383 if ( string . IsNullOrEmpty ( tokenType ) )
8484 throw new ArgumentException ( Prompts . ExceptionArgumentNullOrEmpty , nameof ( tokenType ) ) ;
85- if ( tokenType . Contains ( "|" ) )
85+ if ( tokenType . Contains ( '|' ) )
8686 throw new ArgumentException ( Prompts . ExceptionArgumentContainsPipe , nameof ( tokenType ) ) ;
8787 cancellationToken . ThrowIfCancellationRequested ( ) ;
8888 tokenType = tokenType . Trim ( ) ;
@@ -95,6 +95,8 @@ public async Task<string> GetTokenAsync(string tokenType, bool forceRefetch, Can
9595 if ( site . SiteInfo . Version < v117 && tokenType == "patrol" )
9696 realTokenType = "edit" ;
9797 // Use csrf token if possible.
98+ // https://www.mediawiki.org/wiki/MediaWiki_1.37/Deprecation_of_legacy_API_token_parameters
99+ // https://github.com/wikimedia/mediawiki/blob/1.19.10/includes/api/ApiQueryInfo.php
98100 if ( site . SiteInfo . Version >= v124 && CsrfTokens . Contains ( tokenType ) )
99101 realTokenType = "csrf" ;
100102 // Collect tokens from cache
@@ -156,7 +158,7 @@ string ExtractToken(IDictionary<string, JsonNode?> jTokens, string tokenType1)
156158 }
157159 var token = ( string ? ) jtoken ;
158160 if ( token == null )
159- throw new ArgumentException ( $ "Invalid token type: { tokenType1 } .", nameof ( tokenType ) ) ;
161+ throw new ArgumentException ( $ "Failed to extract { tokenType1 } token from the API response .", nameof ( tokenType ) ) ;
160162 return token ;
161163 }
162164
0 commit comments