Closed tapz closed 7 years ago
Also, would be nice for the signature initializer to accept Int64 instead of NSNumber in Swift...
I modified CLDNetworkCoodinator and added the apiKey to signedRequestParams. Now the server does not respond with apiKey error anymore, but invalid signature.
CLDNetworkCoodinator.swift:
fileprivate func getSignedRequestParams(_ requestParams: CLDRequestParams) -> [String : Any] {
var params: [String : Any] = requestParams.params
if let signatureObj = requestParams.signature,
--> let apiKey = config.apiKey
{
params[CLDSignature.SignatureParam.Signature.rawValue] = signatureObj.signature
params[CLDSignature.SignatureParam.Timestamp.rawValue] = signatureObj.timestamp
--> params[CLDNetworkCoordinatorConsts.API_KEY] = apiKey
}
else if let apiSecret = config.apiSecret, let apiKey = config.apiKey {
let timestamp = Int(Date().timeIntervalSince1970)
params[CLDSignature.SignatureParam.Timestamp.rawValue] = cldParamValueAsString(value: timestamp)
let signature = cloudinarySignParamsUsingSecret(params, cloudinaryApiSecret: apiSecret)
params[CLDSignature.SignatureParam.Signature.rawValue] = signature
params[CLDNetworkCoordinatorConsts.API_KEY] = apiKey
}
else {
printLog(.error, text: "Must supply api key and secret for a signed request")
}
return params
}
Turns out the signature timestamp is not added to the request at all! Only [String], String and Bool parameters are added. Did you try to use the signed requests even once before releasing the version 2 of the SDK??
CLDNetworkDelegate.swift
for key in parameters.keys {
if let value = parameters[key], value is [String] {
...
} else if let value = parameters[key] as? String {
...
} else if let value = parameters[key] as? Bool {
..
}
SUPPORT FOR INT/INT64 PARAMETERS MISSING!
Hi Tapani, Thank you for pointing out these issues. We are looking into it and are working to resolve this as quick as possible. See #61 for momentary workaround for the signature issue.
This issue should be resolved by the latest release, v2.0.2. Please let us know if it works for you now?
Closing this issue due to the time elapsed. Please feel free to either re-open the issue, contact our support http://support.cloudinary.com or create a new ticket if you have any additional issues.
I get this error even when I set the api key to the Config and it's not empty. I'm using a signed upload.