Forum Academy Marketplace Showcase Pricing Features

Help needed - API Workflow with sha256 HMAC signature

Hi all, I’m having an issue creating a API call signature for the Coinbase Pro API (Coinbase Pro | API Reference). Specific questions at bottom of post.

Each request required the following headers


With CB-ACCESS-SIGN having the following structure:

var crypto = require('crypto');

var secret = 'PYPd1Hv4J6/7x...';

var timestamp = / 1000;
var requestPath = '/orders';

var body = JSON.stringify({
    price: '1.0',
    size: '1.0',
    side: 'buy',
    product_id: 'BTC-USD'
var method = 'POST';

// create the prehash string by concatenating required parts
var what = timestamp + method + requestPath + body;

// decode the base64 secret
var key = Buffer(secret, 'base64');

// create a sha256 hmac with the secret
var hmac = crypto.createHmac('sha256', key);

// sign the require message with the hmac
// and finally base64 encode the result
return hmac.update(what).digest('base64');

Therefore I need to be able to dynamically input the following fields:
CB-ACESS-KEY - for each user
CB-ACESS-SIGN - for each call with timestamp, request path, body, secret and method being variables.
CB-ACESS-KEY - to be same as timestamp in CB-ACCESS-SIGN
CB-ACESS-PASSPHRASE - for each user

My current plan was to set up an API workflow in the following structure:
1 - Set UNIX time for timestamp
2 - Create signature (by calling a separate Create Signature workflow) with variables outlined for each call / user (timestamp, request path, body, secret and method). Using the following Plugin (Encode Decode Encrypt Decrypt Plugin | Bubble).
3 - Call the API connector I created for Coinbase Pro with: 1) the timstamp created in step 1, 2) the signature created in step 2, 3) the users ACCESS-KEY and 4) the users ACCESS-PASSPHRASE.

Questions I need help with:
A - is the API workflow structure I set out the correct way to approach this? I’m new to API workflows and feel I may be missing something obvious.
B - When I try and call the Create Signature workflow in step 2 I can’t access the plugin I need to create the signature. Do I need to adjust a setting to make this visible?
– I’m using this plugin after seeing it recommended by @jarrad in this thread - Base64 decoding
– Would the Toolbox plugin (Toolbox Plugin | Bubble) be a better option?

Did you find a way to solve this?

Hey, I did end up solving this.

Created a personal API plugin directly for it.