> For the complete documentation index, see [llms.txt](https://pgprints.gitbook.io/api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pgprints.gitbook.io/api/authentication.md).

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

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="/files/PBkqQUW0Y3UklfNOyxxL" 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="/files/7uwwSZzi8DDhfP8OQ6DQ" 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="/files/ScVy8op9tEDvouqpJxvp" 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="/files/gMMUGAk0ODvHoUeBmlMb" alt=""><figcaption><p>Generator X-PGPrints-Hmac-Sha256</p></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://pgprints.gitbook.io/api/authentication.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
