i want build project with OAuth1
and i found sign request like this :
Authorization:
OAuth oauth_consumer_key="xvz1evFS4wEEPTGEFPHBog",
oauth_nonce="kYjzVBB8Y0ZFabxSWbWovY3uYSQ2pTgmZeNu2VS4cg",
oauth_signature="tnnArxj06cWHq44gCs1OSKk%2FjLY%3D",
oauth_signature_method="HMAC-SHA1",
oauth_timestamp="1318622958",
oauth_token="370773112-GmHxMAgYyLbNEtIKZeRNFsMKPR9EyMZeS9weJAEb",
oauth_version="1.0"
but, how i can got
oauth_signature, oauth_nonce, oauth_timestamp ?
how to make it without Postman ?
Use library OAuthSwiftAlamofire
No need to create oauth_signature , oauth_nonce and oauth_timestamp manually.Check the sample code
let oauthswift = self.getAuth1Object()
oauthswift.client.credential.oauthToken = kAuthToken
oauthswift.client.credential.oauthTokenSecret = kAuthTokenSecret
let sessionManager = SessionManager.default
sessionManager.adapter = OAuthSwiftRequestAdapter(oauthswift)
let api = sessionManager.request(strURL,method: .post, parameters: parameters, encoding: JSONEncoding.default,headers: ["Content-Type" :"application/json"])
And this is your getAuth1Object()
func getAuth1Object() -> OAuth1Swift {
let oauthswift = OAuth1Swift(
consumerKey: "put your consumer key here",
consumerSecret: "put your consumer secret here",
requestTokenUrl: "",
authorizeUrl: "",
accessTokenUrl: ""
)
return oauthswift
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.