Basic Authentication with Alamofire

前端 未结 6 1815
轻奢々
轻奢々 2020-12-15 05:41

Experiencing an issue when authenticating with Basic Auth. I am using a standard enum that conforms to URLRequestConvertible protocol to construct my requests.

6条回答
  •  执笔经年
    2020-12-15 06:23

    Alamofire provides an even easier approach than manually creating your own headers.

    The relevant piece of code from "Basic Auth" section here:

      manager.request(.GET, "https://api.parse.com/1/classes/Spot/")
        .authenticate(user: username, password: password)
        .responseSpotsArray { response in
          completionHandler(response.result)
        }
    

提交回复
热议问题