@@ -483,7 +483,9 @@ public async Task Malformed_identity_token_on_token_response_should_fail()
483483 [ Fact ]
484484 public async Task Authorize_should_push_parameters_when_PAR_is_enabled ( )
485485 {
486- // Configure the client for PAR, authenticating with a client secret
486+ // Configure the client for PAR, authenticating with a client secret.
487+ // The default TokenClientCredentialStyle is PostBody, so the client
488+ // secret should be sent in the POST body (not the Authorization header).
487489 _options . ClientSecret = "secret" ;
488490 _options . ProviderInformation . PushedAuthorizationRequestEndpoint = "https://this-is-set-so-par-will-be-used" ;
489491 var client = new OidcClient ( _options ) ;
@@ -507,7 +509,44 @@ public async Task Authorize_should_push_parameters_when_PAR_is_enabled()
507509 startUrlQueryParams . GetValues ( "client_id" ) . Single ( ) . ShouldBe ( "client" ) ;
508510 startUrlQueryParams . GetValues ( "request_uri" ) . Single ( ) . ShouldBe ( requestUri ) ;
509511
510- // Validate that the client authentication during the PAR request was correct
512+ // Validate that the client authentication during the PAR request used PostBody
513+ var parRequest = backChannelHandler . Request ;
514+ parRequest . Headers . Authorization . ShouldBeNull ( ) ;
515+ var parContent = await parRequest . Content . ReadAsStringAsync ( ) ;
516+ var parParams = HttpUtility . ParseQueryString ( parContent ) ;
517+ parParams . GetValues ( "client_id" ) . Single ( ) . ShouldBe ( "client" ) ;
518+ parParams . GetValues ( "client_secret" ) . Single ( ) . ShouldBe ( "secret" ) ;
519+ }
520+
521+ [ Fact ]
522+ public async Task Par_should_use_authorization_header_when_configured ( )
523+ {
524+ // Configure the client for PAR with AuthorizationHeader credential style
525+ _options . ClientSecret = "secret" ;
526+ _options . TokenClientCredentialStyle = ClientCredentialStyle . AuthorizationHeader ;
527+ _options . ProviderInformation . PushedAuthorizationRequestEndpoint = "https://this-is-set-so-par-will-be-used" ;
528+ var client = new OidcClient ( _options ) ;
529+
530+ // Mock the response from the par endpoint
531+ var requestUri = "mocked_request_uri" ;
532+ var parResponse = new Dictionary < string , string >
533+ {
534+ { "request_uri" , requestUri }
535+ } ;
536+ var backChannelHandler = new NetworkHandler ( JsonSerializer . Serialize ( parResponse ) , HttpStatusCode . OK ) ;
537+ _options . BackchannelHandler = backChannelHandler ;
538+
539+ // Prepare the login to cause the backchannel PAR request
540+ var state = await client . PrepareLoginAsync ( cancellationToken : _ct ) ;
541+
542+ // Validate that the resulting PAR state is correct
543+ var startUrl = new Uri ( state . StartUrl ) ;
544+ var startUrlQueryParams = HttpUtility . ParseQueryString ( startUrl . Query ) ;
545+ startUrlQueryParams . Count . ShouldBe ( 2 ) ;
546+ startUrlQueryParams . GetValues ( "client_id" ) . Single ( ) . ShouldBe ( "client" ) ;
547+ startUrlQueryParams . GetValues ( "request_uri" ) . Single ( ) . ShouldBe ( requestUri ) ;
548+
549+ // Validate that the client authentication during the PAR request used AuthorizationHeader
511550 var request = backChannelHandler . Request ;
512551 request . Headers . Authorization . ShouldNotBeNull ( ) ;
513552 request . Headers . Authorization . Scheme . ShouldBe ( "Basic" ) ;
0 commit comments