ios - AFNetworking setAuthorizationHeaderWithUsername:password: vs. setDefaultCredential -


i'm using afnetworking , associated goodies, , i've subclassed afoauth2client oauth work tokens , forth.

for testing purposes, i'm working on dev server requires username & password access pages/api endpoints. when browse 1 of pages, little dialog box, enter credentials, , i'm time. understand "basic authentication" or "basic access authentication".

so when instantiate afoauth2client subclass, use

[self setauthorizationheaderwithusername:@"user" password:@"pass"]; 

with appropriate username , password type browser when prompted, when attempt access dev server, using httpoperationwithrequest: method, rejected.

so instead, when instantiate client, try:

nsurlcredential *credential = [nsurlcredential credentialwithuser:@"user" password:@"pass" persistence:nsurlcredentialpersistencenone]; [self setdefaultcredential:credential]; 

and works fine requests make; server lets me in.

now far understand, first method setting authorization: http header credentials, , second method tells request when gets challenged, set authorization: http header credentials...same thing, no?

why first method fail , second 1 succeed?


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -