我用的是漫威API。
我设置了时间戳、每个set和散列(ts+privateKey+apiKey).md5
// ts
let ts = String(Date().timeIntervalSince1970)
// apiKey
"cfd8392fa89be1a574b402a9c54f9c52"
// privateKey
"d3ea745cf73f7a7278e1368ffe3b50f4bdb2746"我使用Postman.But进行了测试--响应总是401无效凭据。
/// URL
https://gateway.marvel.com:443/v1/public/characters?ts=1649942740.2140222&apikey=cfd8392fa89be1a574b402a9c54f9c52&hash=d9a73e6105271137942b5ea743ae2ad2{
"code": "InvalidCredentials",
"message": "That hash, timestamp and key combination is invalid."
}我已经在我的开发者账户-漫威设置了一个有*(星号)的授权裁判
请帮帮我。我不知道我错过了什么。
发布于 2022-04-14 20:49:04
将时间戳、私钥和公钥转换为md5哈希。然后将其用于查询字符串。
import CryptoKit
let ts = String(Date().timeIntervalSince1970)
let hash = MD5(string:"\(ts)\("PRIVATE_KEY")\("PUBLIC_KEY")")
func MD5(string: String) -> String {
let digest = Insecure.MD5.hash(data: string.data(using: .utf8) ?? Data())
return digest.map {
String(format: "%02hhx", $0)
}.joined()
}https://stackoverflow.com/questions/71872903
复制相似问题