@@ -69,17 +69,18 @@ public virtual async Task<ClientCredentialsToken> RequestToken(
69
69
ClientId = client . ClientId ,
70
70
ClientSecret = client . ClientSecret ,
71
71
ClientCredentialStyle = client . ClientCredentialStyle ,
72
+ AuthorizationHeaderStyle = client . AuthorizationHeaderStyle
72
73
} ;
73
74
74
75
request . Parameters . AddRange ( client . Parameters ) ;
75
-
76
+
76
77
parameters ??= new TokenRequestParameters ( ) ;
77
-
78
+
78
79
if ( ! string . IsNullOrWhiteSpace ( parameters . Scope ) )
79
80
{
80
81
request . Scope = parameters . Scope ;
81
82
}
82
-
83
+
83
84
if ( ! string . IsNullOrWhiteSpace ( parameters . Resource ) )
84
85
{
85
86
request . Resource . Clear ( ) ;
@@ -103,14 +104,14 @@ public virtual async Task<ClientCredentialsToken> RequestToken(
103
104
else
104
105
{
105
106
var assertion = await _clientAssertionService . GetClientAssertionAsync ( clientName ) . ConfigureAwait ( false ) ;
106
-
107
+
107
108
if ( assertion != null )
108
109
{
109
110
request . ClientAssertion = assertion ;
110
111
request . ClientCredentialStyle = ClientCredentialStyle . PostBody ;
111
112
}
112
113
}
113
-
114
+
114
115
request . Options . TryAdd ( ClientCredentialsTokenManagementDefaults . TokenRequestParametersOptionsName , parameters ) ;
115
116
116
117
var key = await _dPoPKeyMaterialService . GetKeyAsync ( clientName ) ;
@@ -134,19 +135,19 @@ public virtual async Task<ClientCredentialsToken> RequestToken(
134
135
}
135
136
else if ( ! string . IsNullOrWhiteSpace ( client . HttpClientName ) )
136
137
{
137
- httpClient = _httpClientFactory . CreateClient ( client . HttpClientName ) ;
138
+ httpClient = _httpClientFactory . CreateClient ( client . HttpClientName ) ;
138
139
}
139
140
else
140
141
{
141
- httpClient = _httpClientFactory . CreateClient ( ClientCredentialsTokenManagementDefaults . BackChannelHttpClientName ) ;
142
+ httpClient = _httpClientFactory . CreateClient ( ClientCredentialsTokenManagementDefaults . BackChannelHttpClientName ) ;
142
143
}
143
-
144
+
144
145
_logger . LogDebug ( "Requesting client credentials access token at endpoint: {endpoint}" , request . Address ) ;
145
146
var response = await httpClient . RequestClientCredentialsTokenAsync ( request , cancellationToken ) . ConfigureAwait ( false ) ;
146
147
147
- if ( response . IsError &&
148
- ( response . Error == OidcConstants . TokenErrors . UseDPoPNonce || response . Error == OidcConstants . TokenErrors . InvalidDPoPProof ) &&
149
- key != null &&
148
+ if ( response . IsError &&
149
+ ( response . Error == OidcConstants . TokenErrors . UseDPoPNonce || response . Error == OidcConstants . TokenErrors . InvalidDPoPProof ) &&
150
+ key != null &&
150
151
response . DPoPNonce != null )
151
152
{
152
153
_logger . LogDebug ( "Token request failed with DPoP nonce error. Retrying with new nonce." ) ;
@@ -173,7 +174,7 @@ public virtual async Task<ClientCredentialsToken> RequestToken(
173
174
Error = response . Error
174
175
} ;
175
176
}
176
-
177
+
177
178
return new ClientCredentialsToken
178
179
{
179
180
AccessToken = response . AccessToken ,
0 commit comments