πŸ”Authentication

Authorization is an important step to using Open API. To be able to authenticate the store, you must generate a X-PGPrints-Hmac-Sha256. first of all you must have Secret Key.

Generator Secret Key:

Back in the Key Management section in the app, click the Generate Key button to get the secret key and copy the key

Generator X-PGPrints-Hmac-Sha256:

Make X-PGPrints-Hmac-Sha256 very simple by following steps:

  1. Converts body value to a JSON string

  2. Use the newly obtained secret key to make the key code

  3. Use Json String body to the plain text

  4. Use Sha256 to algorithm

  5. Generator X-PGPrints-Hmac-Sha256

This is my code in some language:

const crypto = require('crypto');
const generatePGPrintHmac = (content) => {
    const { body, secretKey } = content;
    // your body and your secrect key
    const sign = crypto
        .createHmac("sha256", secretKey )
        .update(JSON.stringify(body))
        .digest("hex");
    return sign;
}

Other: Use the website to generator Sha256: https://www.devglan.com/online-tools/hmac-sha256-online

  1. Open the website, press the F12 key and then select the Console section to convert body value to a JSON string:

  1. Copy the above JSON into the Enter Plain Text to Compute Hash field of the website:

  1. Enter the secret key generated above in the Enter the Secret Key field:

  1. Select Cryptographic Hash Function: SHA-256, Output Text Format: Base 64 and click the Computer Hash button to get the Hash for the API:

Last updated