i build project swift with OAuth and i already got Acces Token from my API Login and then i want get data from API JSon with my acces token. so, how to use OAuth get request http method with OAuth and my acces token
i have json parse standar without OAuth
i'm used Librabry https://github.com/OAuthSwift/OAuthSwift
in there i got Signed Request (Readme.md) like this
but im confused how to add my Acces Token, Consumer Key and My Consumer Secret to acces my API JSON
i have json parse standar without OAuth
Code:
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()
i'm used Librabry https://github.com/OAuthSwift/OAuthSwift
in there i got Signed Request (Readme.md) like this
Code:
oauthswift.client.get("https://api.linkedin.com/v1/people/~",
success: { response in
let dataString = response.string
print(dataString)
},
failure: { error in
print(error)
}
)
but im confused how to add my Acces Token, Consumer Key and My Consumer Secret to acces my API JSON