> For the complete documentation index, see [llms.txt](https://futuricblock.gitbook.io/futuric-waas-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://futuricblock.gitbook.io/futuric-waas-documentation/futuric-block-wen-dang/xiang-mu-ji-cheng-wen-dang/api-shou-quan-fang-shi.md).

# API授权方式

Futuric-WaaS使用 API 密钥结合签名的概念来授权 API 调用者。

以下示例演示了如何对有效负载进行签名以获取签名并访问“创建用户”API。 在此 API 中，您必须传递 Header 中的“ApiKey”，“Signature”和“SubGuid”值以及原始 Body 中的“subUserId”值。

### POST：创建子用户

[http://demo-waas-gateway.futuricblock.com/api/v2/wallet/user/create?api-version=2.0 ](http://demo-waas-gateway.futuricblock.com/api/v2/wallet/user/create?api-version=2.0)

| 变量名称      | 值类型      | 可选 | 示例                                            |
| --------- | -------- | -- | --------------------------------------------- |
| subUserId | `string` | 否  | `"SUID-32a0fb0e-bdad-4d68-9734-756bdeb24ca9"` |

**查询参数**

| 参数名称        | 值   |
| ----------- | --- |
| api-version | 2.0 |

**主体（JSON）**

```json
{
    "subUserId": "Test_1234"
}
```

**请求示例**

```
curl --location 'http://demo-waas-gateway.futuricblock.com/api/v2/wallet/user/create?api-version=2.0' \
--header 'ApiKey: 4a88c6f1d6d24e46b2b0edd0ad69bac5f' \
--header 'Signature: [Your_Signature]' \
--header 'SubGuid: SUB_00001' \
--data-raw '{
    "subUserId": "SUID-32a0fb0e-bdad-4d68-9734-756bdeb24ca9"
}'

```

要使用RSA 数字签名，您需要将整个原始正文有效负载字符串转换为 Base64 编码字符串，如下所示:

**原本**

```
{
    "subUserId": "Test_1234"
}
```

**Base64 编码后**

```json
eyJzdWIiOiJ2VzVSVWQ0a0lLaVczdzd4dzN4dWlMIn0=
```

然后，您将使用 RSA 私钥对该 Base64数据进行签名以获得签名字串。

{% hint style="info" %}
您应使用 SHA-512与RSA 哈希算法，签名大小为 2048 位整数，与 RSA 密钥大小相对应。
{% endhint %}

您还可以在以下网站中生成并验证签名：

<https://www.base64encode.org/zh/> <https://8gwifi.org/RSAFunctionality?rsasignverifyfunctions=rsasignverifyfunctions&keysize=2048>
