JavaScript to calculate AUTH token for API

Hey !

Need to calculate an AUTH token for my API - anyone knows how i could that ? Tried with toolbox but apparently can’t get the results to save somewhere to use later on… Here’s some information if needed

const crypto = require('crypto');

function calculateOVHSignature(appSecret, consumerKey, method, query, body, timestamp) {
  let data = appSecret + "+" + consumerKey + "+" + method + "+" + query + "+" + body + "+" + timestamp;
  let signature = "$1$" + crypto.createHash('sha1').update(data).digest('hex');
  return signature;
}

// Example usage
const appSecret = "YOUR_APP_SECRET";
const consumerKey = "YOUR_CONSUMER_KEY";
const method = "GET"; // for example
const query = "https://api.ovh.com/1.0/some/endpoint?param=value";
const body = ""; // for GET requests, the body is usually empty
const timestamp = Math.floor(Date.now() / 1000); // current Unix timestamp

const signature = calculateOVHSignature(appSecret, consumerKey, method, query, body, timestamp);
console.log("Signature:", signature);

Is this even possible ? Thanks

  1. I hope you won’t run the script on the client side. That’d be a big security leak.
  2. I made a WF with ur code, you can have a look here: https://bubble.io/page?type=api&id=womusers2023&tab=tabs-2
  3. You can find information on how to deal with a server script here: https://toolboxdocs.netlify.app/

and u’ll get ur desired result like:

Hey ! Thanks for the help :slight_smile: - Can’t seem to get to your example : “User does not have permission to view this document” -

Sorry , there is the right one : Bubble-solutions | Bubble Editor

Thanks - Tested out that setup on my side, but the result seems to come back empty as my “Create a token” flow creates an empty token (arbitrary text is filled in propertything1 & 2) Thanks

check your server script settings , and check logs after you run a schedule API, update your toolbox plugin

Thanks - Got a result, but the token is invalid

Would you be able to help me out a bit further on this on ? I believe that JS code ain’t complete as it’s stated that i need to calculate the signature with the following method

"$1$" + SHA1_HEX(AS+"+"+CK+"+"+METHOD+"+"+QUERY+"+"+BODY+"+"+TSTAMP)

Will keep digging

Thanks a lot,

More info if needed