我使用OAuth構建項目swift,我已經從我的API登錄獲取了Acces令牌,然後我想從我的acces令牌獲取API JSon的數據。因此,如何使用OAuth獲得請求的HTTP方法通過OAuth和我的存取權限令牌如何發送https GET請求與oauth
我有JSON解析STANDAR沒有OAuth的
let url = NSURL(string: "https://conversation.8villages.com/1.0/contents/articles?state=published")
let request = NSMutableURLRequest(url: url! as URL)
request.httpMethod = "GET"
request.addValue("application/json", forHTTPHeaderField: "Authorization")
let task = URLSession.shared.dataTask(with: request as URLRequest) { data,response,error in
guard error == nil && data != nil else {
print("error", error!)
return
}
let httpStatus = response as? HTTPURLResponse
if httpStatus!.statusCode == 200
{
if data?.count != 0
{
let responString = try! JSONSerialization.jsonObject(with: data!, options: .allowFragments)
print(responString)
}
else{
print("No got data from URL")
}
}
else
{
print("error httpstatus code is ", httpStatus!.statusCode)
}
}
task.resume()
我已經習慣Librabry https://github.com/OAuthSwift/OAuthSwift
在那裏我得到簽名的請求(Readme.md)這樣
oauthswift.client.get("https://api.linkedin.com/v1/people/~",
success: { response in
let dataString = response.string
print(dataString)
},
failure: { error in
print(error)
}
)
,但即時通訊混淆如何添加我的艾策斯令牌,使用者密鑰和我的消費者的祕密進入電影我的API JSON
如何考績承載令牌先生?請告訴我:( –