INVALID SIGNATURE

Comments

4 comments

  • Avatar
    Eric Pasos

    Hi Johnson,

    The upload signature is needed when you are performing a signed REST API call. With the error message you get, you will need to calculate the signature by following the procedure as described in the documentation.

    For your case, you could generate the signature as:

    API Secret: 'yourapisecret'
    Parameter to sign: 'folder=Kernel&timestamp=1669284769'

    Creating the SHA-1 signature:
      SHA1('folder=Kernel&timestamp=1669284769yourapisecret')

    For more information, kindly see: https://support.cloudinary.com/hc/en-us/articles/207885595-How-can-I-generate-the-signed-upload-payload-on-my-server-

    0
    Comment actions Permalink
  • Avatar
    johnson owusu prah

    please is there a code error or something ,i have followed and repeated  the recommendations of the doCs yet same error 

     

    ----------THIS IS NOW MY NEW CODE,SHOULD I INCLUDE OR DELETE SOME LINES-----------

    const cloudinary = require('cloudinary').v2 ;
    const {CloudinaryStorage} = require('multer-storage-cloudinary')
    const crypto = require('crypto')

    cloudinary.config({
        cloud_name :  process.env.CLOUDINARY_SECRET,
        api_key :   process.env.CLOUDINARY_KEY,
        api_secret :  process.env.CLOUDINARY_NAME
       
    })

    const storage =new CloudinaryStorage({
        cloudinary,
        params : {
            folder : 'Kernels',
            allowedFormats : ['jpeg','png','jpg']
        }
    })


    // const singnature = SHA1('folder=Kernel&timestamp=1669284769')

    const apiSecret = cloudinary.config().api_secret;
    const SHA1= function(input){
      return crypto.createHash('sha1').update(JSON.stringify(input)).digest('hex')
    }

    const signuploadform = () => {

        const timestamp = Math.round((new Date).getTime()/1000);

        const signature = cloudinary.utils.api_sign_request(SHA1('folder=Kernel&timestamp=timestamp+apiSecret'),
           apiSecret);
     
        return { timestamp, signature }
      }

    module.exports = {
        cloudinary,
        storage,
        signuploadform
    }

     
    0
    Comment actions Permalink
  • Avatar
    Tia Esguerra

    Hi there,

    I would take a look at your cloudinary.config() You seem to have a couple of values out of place, according to what you have shared here. I see that you specified `cloud_name :  process.env.CLOUDINARY_SECRET` and `api_secret :  process.env.CLOUDINARY_NAME`. Instead, please try `api_secret :  process.env.CLOUDINARY_SECRET`  and `cloud_name :  process.env.CLOUDINARY_NAME`

    Let me know how it goes after making those changes. I look forward to your reply. 

    Kind Regards, 

    Tia

    0
    Comment actions Permalink
  • Avatar
    johnson owusu prah

    oh yeas...Thanks so much...Error resolved

    0
    Comment actions Permalink

Please sign in to leave a comment.