@@ -105,6 +105,8 @@ public IOAuth2CodeGenerator CodeGenerator
105105 public async Task < OAuth2AuthorizationCodeResult > GetAuthorizationCodeAsync ( IEnumerable < string > scopes ,
106106 IOAuth2WebBrowser browser , IDictionary < string , string > extraQueryParams , CancellationToken ct )
107107 {
108+ using IDisposable region = Trace2 . StartRegion ( OAuth2Constants . Trace2Category , "get_authcode" ) ;
109+
108110 string state = CodeGenerator . CreateNonce ( ) ;
109111 string codeVerifier = CodeGenerator . CreatePkceCodeVerifier ( ) ;
110112 string codeChallenge = CodeGenerator . CreatePkceCodeChallenge ( OAuth2PkceChallengeMethod . Sha256 , codeVerifier ) ;
@@ -167,8 +169,11 @@ public async Task<OAuth2AuthorizationCodeResult> GetAuthorizationCodeAsync(IEnum
167169
168170 // Open the browser at the request URI to start the authorization code grant flow, and
169171 // intercept the response parameters delivered to the redirect URI.
170- IDictionary < string , string > responseParams =
171- await browser . GetAuthenticationResponseAsync ( authorizationUri , redirectUri , _responseMode , ct ) ;
172+ IDictionary < string , string > responseParams ;
173+ using ( Trace2 . StartRegion ( OAuth2Constants . Trace2Category , "browser" ) )
174+ {
175+ responseParams = await browser . GetAuthenticationResponseAsync ( authorizationUri , redirectUri , _responseMode , ct ) ;
176+ }
172177
173178 // Check for errors serious enough we should terminate the flow, such as if the state value returned does
174179 // not match the one we passed. This indicates a badly implemented Authorization Server, or worse, some
@@ -196,8 +201,7 @@ public async Task<OAuth2AuthorizationCodeResult> GetAuthorizationCodeAsync(IEnum
196201
197202 public async Task < OAuth2DeviceCodeResult > GetDeviceCodeAsync ( IEnumerable < string > scopes , CancellationToken ct )
198203 {
199- var label = "get device code" ;
200- using IDisposable region = Trace2 . StartRegion ( OAuth2Constants . Trace2Category , label ) ;
204+ using IDisposable region = Trace2 . StartRegion ( OAuth2Constants . Trace2Category , "get_devicecode" ) ;
201205
202206 if ( _endpoints . DeviceAuthorizationEndpoint is null )
203207 {
@@ -234,8 +238,7 @@ public async Task<OAuth2DeviceCodeResult> GetDeviceCodeAsync(IEnumerable<string>
234238
235239 public async Task < OAuth2TokenResult > GetTokenByAuthorizationCodeAsync ( OAuth2AuthorizationCodeResult authorizationCodeResult , CancellationToken ct )
236240 {
237- var label = "get token by auth code" ;
238- using IDisposable region = Trace2 . StartRegion ( OAuth2Constants . Trace2Category , label ) ;
241+ using IDisposable region = Trace2 . StartRegion ( OAuth2Constants . Trace2Category , "token_by_authcode" ) ;
239242
240243 var formData = new Dictionary < string , string >
241244 {
@@ -273,8 +276,7 @@ public async Task<OAuth2TokenResult> GetTokenByAuthorizationCodeAsync(OAuth2Auth
273276
274277 public async Task < OAuth2TokenResult > GetTokenByRefreshTokenAsync ( string refreshToken , CancellationToken ct )
275278 {
276- var label = "get token by refresh token" ;
277- using IDisposable region = Trace2 . StartRegion ( OAuth2Constants . Trace2Category , label ) ;
279+ using IDisposable region = Trace2 . StartRegion ( OAuth2Constants . Trace2Category , "token_by_refresh" ) ;
278280
279281 var formData = new Dictionary < string , string >
280282 {
@@ -306,6 +308,8 @@ public async Task<OAuth2TokenResult> GetTokenByRefreshTokenAsync(string refreshT
306308
307309 public async Task < OAuth2TokenResult > GetTokenByDeviceCodeAsync ( OAuth2DeviceCodeResult deviceCodeResult , CancellationToken ct )
308310 {
311+ using IDisposable region = Trace2 . StartRegion ( OAuth2Constants . Trace2Category , "token_by_devicecode" ) ;
312+
309313 var formData = new Dictionary < string , string >
310314 {
311315 [ OAuth2Constants . DeviceAuthorization . GrantTypeParameter ] = OAuth2Constants . DeviceAuthorization . DeviceCodeGrantType ,
0 commit comments