How to pass access token to Alamofire?

前端 未结 4 444
南旧
南旧 2020-12-28 19:19

I am trying to pass access token in Alamofire but getting confuse in various methods around web.

Below are methods which we need to use.



        
4条回答
  •  萌比男神i
    2020-12-28 20:02

    I'm using look like this :-

    let username = "Tuser"
    let password = "Tpassword"
    let credentialData = "\(username):\(password)".data(using: String.Encoding.utf8)!
    let base64Credentials = credentialData.base64EncodedString(options: [])
    let headers = ["Authorization": "Basic \(base64Credentials)"]
    

    OR

    let headers    = [ "Authorization" : token ]
    

提交回复
热议问题