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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -