File tree Expand file tree Collapse file tree
crates/rmcp/src/transport Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -744,6 +744,11 @@ impl AuthorizationRequest {
744744 }
745745
746746 /// Set the client secret paired with a pre-registered client ID.
747+ ///
748+ /// Must be used together with
749+ /// [`with_preregistered_client`](Self::with_preregistered_client);
750+ /// authorization fails with [`AuthError::RegistrationFailed`] if a secret
751+ /// is provided without a client ID.
747752 pub fn with_client_secret ( mut self , client_secret : impl Into < String > ) -> Self {
748753 self . client_secret = Some ( client_secret. into ( ) ) ;
749754 self
@@ -3072,6 +3077,17 @@ impl AuthorizationSession {
30723077 mut auth_manager : AuthorizationManager ,
30733078 mut request : AuthorizationRequest ,
30743079 ) -> Result < Self , ( AuthorizationManager , AuthError ) > {
3080+ if request. client_secret . is_some ( ) && request. client_id . is_none ( ) {
3081+ return Err ( (
3082+ auth_manager,
3083+ AuthError :: RegistrationFailed (
3084+ "client_secret was provided without a pre-registered client_id; \
3085+ pair with_client_secret with with_preregistered_client"
3086+ . to_string ( ) ,
3087+ ) ,
3088+ ) ) ;
3089+ }
3090+
30753091 if request. scopes . is_empty ( ) {
30763092 request. scopes = auth_manager. select_scopes ( None , & [ ] ) ;
30773093 } else {
You can’t perform that action at this time.
0 commit comments