Попробуйте этот код
let config = URLSessionConfiguration.default
let session = URLSession(configuration: config)
let url = URL(string:"https://johnsmith.s3.amazonaws.com")!
let request = NSMutableURLRequest(url: url)
request.timeoutInterval = 60
request.addValue("application/json; charset=utf-8", forHTTPHeaderField: "Content-Type")
request.httpMethod = "GET"
request.addValue(" "AWS" + " " + AWSAccessKeyId + ":" + Signature", forHTTPHeaderField: "Authorization")
let task = session.dataTask(with: request as URLRequest) { (data, response, error) in
// (data, response, error) in
if error != nil {
print(error!.localizedDescription)
} else {
do {
let json = try JSONSerialization.jsonObject(with: data! as Data, options: .allowFragments)
print("json data")
} catch {
print("error in JSONSerialization")
}
}
}
task.resume()