@@ -136,16 +136,32 @@ private static async Task<InteractiveBrowserCredential> GetInteractiveBrowserCre
136136 if ( IsATPoPSupported ( ) )
137137 {
138138 // Logic to implement ATPoP Authentication
139- var client = new PopClient ( interactiveBrowserCredential , authContext , new PopClientOptions ( )
140- {
141- Diagnostics =
142- {
143- IsLoggingContentEnabled = true ,
144- LoggedHeaderNames = { "Authorization" }
145- }
139+ authRecord = await Task . Run ( ( ) =>
140+ {
141+ var popTokenAuthenticationPolicy = new PopTokenAuthenticationPolicy ( interactiveBrowserCredential as ISupportsProofOfPossession , $ "https://graph.microsoft.com/.default") ;
142+
143+ var pipelineOptions = new HttpPipelineOptions ( new PopClientOptions ( )
144+ {
145+ Diagnostics =
146+ {
147+ IsLoggingContentEnabled = true ,
148+ LoggedHeaderNames = { "Authorization" }
149+ } ,
150+ } ) ;
151+ pipelineOptions . PerRetryPolicies . Add ( popTokenAuthenticationPolicy ) ;
152+
153+ var _pipeline = HttpPipelineBuilder . Build ( pipelineOptions , new HttpPipelineTransportOptions { ServerCertificateCustomValidationCallback = ( _ ) => true } ) ;
154+ using var request = _pipeline . CreateRequest ( ) ;
155+ request . Method = RequestMethod . Get ;
156+ request . Uri . Reset ( new Uri ( "https://20.190.132.47/beta/me" ) ) ;
157+ var response = _pipeline . SendRequest ( request , cancellationToken ) ;
158+ var message = new HttpMessage ( request , new ResponseClassifier ( ) ) ;
159+
160+ // Manually invoke the authentication policy's process method
161+ popTokenAuthenticationPolicy . ProcessAsync ( message , ReadOnlyMemory < HttpPipelinePolicy > . Empty ) ;
162+ // Run the thread in MTA.
163+ return interactiveBrowserCredential . Authenticate ( new TokenRequestContext ( authContext . Scopes ) , cancellationToken ) ;
146164 } ) ;
147- //var response = client.Get(new Uri("https://20.190.132.47/beta/me"), CancellationToken.None);
148- authRecord = client . GetAuthRecord ( ) ;
149165 }
150166 else
151167 {
@@ -471,4 +487,7 @@ public static Task DeleteAuthRecordAsync()
471487 return Task . CompletedTask ;
472488 }
473489 }
490+ internal class PopClientOptions : ClientOptions
491+ {
492+ }
474493}
0 commit comments