ios - Authentication Challenge Method Is Not Called When Using NSURLSession Custom Delegate -


I am working on an iOS app that connects through secure services from the SSP.NET Web API. I want to use a custom representative to handle the authentication challenge. But the representative method is not called.

The http request is written in the following method within a view controller:

  - (IBAction) test: (UIButton *) this {// Beer Token KeychainItemWrapper Go * Key Keys of ITEM = [[Key Itamwapper Alok] Init With Identifier: @ "BearTotoken" Access Group: Nile]; NSSTING * BEARER TOKEN = [Key key ITEM ObjectForcae: (__Bridge ID) (KSACVAdata)]; // configuration request NSURL * url = [NSURL URLWithString: @ "......"]; // Replace with real IP address .... NSMutableURLRequest * Request = [NSMutableURL request request with url: url]; [Set http system: @ "gET"]; [Request Set Value: [NSString stringWithFormat: @ "Bearer% @", Banner Talk] forHTTPHeaderField: @ "Authority"]; // Configure session NSURLSessionConfiguration * Configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; AuthChallengeDelegate * authChallengeDel = [[AuthChallengeDelegate alloc] init]; NSURL session * session = [configuration with NSURL session session: Configuration Representative: authChallengeDel rep Queue: zero]; NSURLSessionDataTask * Task = [Session Dataset request request: request]; [Resume work]; }   

In the AuthChallengeDelegate class, I have implemented the following method:

  - (zero) URLSession: (NSURLSession *) session dataTask: (NSURLSessionDataTask * ) DataTask didReceiveResponse: (NSURLResponse *) response completionHandler: (zero (^) (NSURLSessionResponseDisposition flair)) completionHandler {NSLog (@ "% @", response); } - (zero) URLSession: (NSURLSession *) session didReceiveChallenge: (NSURLAuthenticationChallenge *) Challenge completionHandler: (zero (^) (NSURLSessionAuthChallengeDisposition temperament, NSURLCredential * credentials) completionHandler {NSLog (@ "challenge method was obtained" ); NSLog (@ "% @", challenge.protectionSpace.authenticationMethod); }   

The first method (The Reverse Response) is called and the response status code 401 is "Www-Authenticate" = Bearer in "Head-Field". But the second method (Reciev Challenge) is not called.

Important: URL loading system class to your rivals Do not call requests to handle the challenges until the server happens. The response includes a WWW-authentication header. is said only when the header looks like '' WWW-Authenticate ':' Basic '

I did not find any solution to handle token based authentication As for the question using authentication challenges such as 'WWW-authentication': 'barrier'

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -