@@ -15,6 +15,11 @@ public static IOpenApi Create(OpenApiOptions options)
1515 {
1616 HttpClient httpClient ;
1717 RestClient restClient ;
18+ var opts = new RestClientOptions ( )
19+ {
20+ ThrowOnAnyError = false ,
21+ Authenticator = new OAuth2AuthorizationRequestHeaderAuthenticator ( options . BotInfo . FullToken , "Bot" )
22+ } ;
1823 if ( options . Retry )
1924 {
2025 /*
@@ -25,10 +30,7 @@ public static IOpenApi Create(OpenApiOptions options)
2530 .OrResult(x => x.StatusCode is >= HttpStatusCode.InternalServerError or HttpStatusCode.RequestTimeout or HttpStatusCode.GatewayTimeout)
2631 .WaitAndRetryAsync(Backoff.DecorrelatedJitterBackoffV2(TimeSpan.FromSeconds(1), 5));
2732 */
28- var opts = new RestClientOptions ( )
29- {
30- ThrowOnAnyError = false
31- } ;
33+
3234 var handler = new PolicyHttpMessageHandler ( DecorrelatedJitterBackoffV2 . GetRetryIntervals ( options . RetryCount , options . RetryInterval ) , new LoggerHttpHandler ( ) ) ;
3335 httpClient = new ( handler ) ;
3436 httpClient . BaseAddress = new Uri ( options . BotInfo . SandBox ? "https://sandbox.api.sgroup.qq.com/" : "https://api.sgroup.qq.com/" ) ;
@@ -38,10 +40,8 @@ public static IOpenApi Create(OpenApiOptions options)
3840 {
3941 httpClient = new ( new LoggerHttpHandler ( ) ) ;
4042 httpClient . BaseAddress = new Uri ( options . BotInfo . SandBox ? "https://sandbox.api.sgroup.qq.com/" : "https://api.sgroup.qq.com/" ) ;
41- restClient = new ( httpClient ) ;
43+ restClient = new ( httpClient , opts ) ;
4244 }
43- // 添加验证Header "Bot {appId}.{token}"
44- restClient . UseAuthenticator ( new OAuth2AuthorizationRequestHeaderAuthenticator ( options . BotInfo . FullToken , "Bot" ) ) ;
4545 return new OpenApi ( restClient , httpClient ) ;
4646 }
4747 }
0 commit comments