# 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

<figure><img src="https://lh3.googleusercontent.com/VPBb8T1bBrSGGNI4O-xT01oTYq18W2l7QjGbEaCMtv75nonw-ODl300hwkYFOZ8gkJz4Pc1beuxN49ToJyZ584yz_JADMqXpI78_-scWrHvSnVXIDUN9F-JAbVp3rfpznIixJtwkSHHipxG_xbusdiE" alt=""><figcaption><p>Generate Key</p></figcaption></figure>



### 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:

{% tabs %}
{% tab title="Javascript" %}
<pre class="language-javascript"><code class="lang-javascript">const crypto = require('crypto');
<strong>const generatePGPrintHmac = (content) => {
</strong>    const { body, secretKey } = content;
    // your body and your secrect key
    const sign = crypto
        .createHmac("sha256", secretKey )
        .update(JSON.stringify(body))
        .digest("base64");
    return sign;
}
</code></pre>


{% endtab %}
{% endtabs %}

Other: Use the website to generator Sha256: [https://www.devglan.com/online-tools/hmac-sha256-online](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:

<figure><img src="https://3814087252-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Gc71SEwOSQuXDyaV0m8%2Fuploads%2FnqgxnP5DNpxzWXQqnB6v%2Fimage.png?alt=media&#x26;token=3ac30ef4-536d-4aa2-9387-bbc28a38f19d" alt=""><figcaption><p>Generate JSON</p></figcaption></figure>

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

<figure><img src="https://3814087252-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Gc71SEwOSQuXDyaV0m8%2Fuploads%2F6UXLxkr2fo2ZusvVTsSQ%2Fimage.png?alt=media&#x26;token=90d21164-f39b-4f66-9811-1e34f173edba" alt=""><figcaption><p>Enter JSON in the <strong>Enter Plain Text to Compute Hash box</strong></p></figcaption></figure>

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

<figure><img src="https://3814087252-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Gc71SEwOSQuXDyaV0m8%2Fuploads%2FE6cVKgEt0onnNONe8o2o%2Fimage.png?alt=media&#x26;token=b39870e9-9e28-4341-ba5f-8d391ac0597a" alt=""><figcaption><p>Enter the secret key in the <strong>Enter the Secret Key</strong> field</p></figcaption></figure>

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

<figure><img src="https://3814087252-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Gc71SEwOSQuXDyaV0m8%2Fuploads%2FzQELyNcs5l0LtAPwddzH%2Fimage.png?alt=media&#x26;token=2e8cb10f-6cf0-4299-9c0e-6362e806da3d" alt=""><figcaption><p>Generator X-PGPrints-Hmac-Sha256</p></figcaption></figure>
