我有Consumer Key,Consumer Secret,Token Key和Token Secret来获取Data API。在邮递员中这样:
我必须在上面的捕获邮递员中获取我的API数据。那么我有Alamofire的方法请求:
Alamofire.request("https://conversation.8villages.com/1.0/contents/articles?state=published", headers: headers).responseJSON { response in
print("test", response.request!) // original URL request
print("ini responseny", response.response!) // HTTP URL response
print("test", response.data!) // server data
print("test", response.result) // result of response serialization
if let JSON = response.result.value {
print("JSON: \(JSON)")
}
}
所以,我不知道如何在方法get中添加或传递我的令牌。请有人帮助我。
我正在使用 OAuthSwift 和 Alamofire 。
答案 0 :(得分:0)
试试这个
let headers: HTTPHeaders = [
"Authorization": "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==",
"Accept": "application/json"
]
Alamofire.request("https://httpbin.org/headers", headers: headers).responseJSON { response in
debugPrint(response)
}