gpt4 book ai didi

ios - 如何生成签名方法OAuth1

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:10:58 24 4
gpt4 key购买 nike

我想用 OAuth1 构建项目,我发现了这样的签名请求:

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"

但是,我怎么能得到

oauth_signature, oauth_nonce, oauth_timestamp ?

没有 Postman 怎么办?

最佳答案

使用库 OAuthSwiftAlamofire

无需手动创建oauth_signatureoauth_nonceoauth_timestamp查看示例代码

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"])

这是您的 getAuth1Object()

func getAuth1Object() -> OAuth1Swift {
let oauthswift = OAuth1Swift(
consumerKey: "put your consumer key here",
consumerSecret: "put your consumer secret here",
requestTokenUrl: "",
authorizeUrl: "",
accessTokenUrl: ""
)
return oauthswift
}

关于ios - 如何生成签名方法OAuth1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43729085/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com