authentication - Auth Challenge Alamofire 2.0 -
since updated our project swift 2 , alamofire version 2.0 observe following behavior regarding base auth: when send request (no matter kind of) authentication set, request sent without authentication header first time. after backend answers status code 401, alamofire adds authentication header , and resends request once again. send request using following snipped:
alamofire.request(request).authenticate(user: config.serviceauthuser, password: config.serviceauthpassword)
is there way force alamofire include authentiation header in every request? want avoid kind of auth challenge every request lower network , server traffic. had 1 solution working ios8, added auth header in session config of shared instance of alamofires manager follows:
alamofire.manager.sharedinstance.session.configuration.httpadditionalheaders = authheader
but ios9 not work anymore, since copy of configuration object returned , modified.
is there way avaoid auth challenge process , force alamofire include auth header every request?
making 2 requests how underlying url loading system designed apple. alamofire authenticate
methods allow provide credentials supply challenge if occurs.
if want provide header directly, use headers
parameter on request
method. additionally, insert user:password
credentials directly url.
Comments
Post a Comment