When a client attempts to connect to a host (like a relay server), this connection is authenticated with a basic authentication challenge. To setup a HTTP basic authentication, the application registers a delegate with the OData SDK. If the ODPHTTPAuthChallengeListenerDelegate is not registered, an HTTP_AUTH_FAILURE error is returned when a challenge is received.
To register a listener for basic authentication, implement the protocol ODPHTTPAuthChallengeListenerDelegate
@protocol ODPHTTPAuthChallengeListenerDelegate <NSObject> @required -(void) onHTTPAuthChallenge:(NSString*)host forUser:(NSString*)userName withRealm:(NSString*)realm; @end
+ (void) httpAuthChallengeResult: (BOOL) credentialsSupplied forUser: (NSString*) userName withPassword: (NSString*) password
-(void) onHTTPAuthChallenge:(NSString*)hostforUser:(NSString*)userName withRealm:(NSString*)realm { NSLog(@"%@--%@--%@", host, userName, realm); [ODPClientListeners httpAuthChallengeResult:YES forUser:userName withPassword:realm; } -(IBAction)httpsCheck:(UIButton*)button { @try { LiteSUPUserManager* manager = [LiteSUPUserManager getInstance:@"NewFlight"]; [ODPClientListeners setHTTPAuthChallengeListenerDelegate:self]; [LiteSUPMessagingClient enableHTTPS:NO]; [manager setConnectionProfile:@<host> withSupPort:<port> withServerFarmID:@<farmID>]; [manager registerUser:@<supuser> withSecurityConfig:@<securityconfig> withPassword:@<password>]; } @catch (NSException *exception) { NSLog(@"%@", [exception callStackSymbols]); NSLog(@"%@", [[exception userInfo] objectForKey:@"ErrorCode"]); } }