# 跨平台身份链接

## <mark style="color:blue;">GET</mark> /api/v1/crossPlatformIdentityLinking

* 说明： 通过这个 API，你将可以在获得用户授权的前提下，查询用户 Web2 账号关联的 Web3 地址或 Web3 地址关联的 Web2 账号，并验证这些账号是不是属于同一个人。该数据需用 [Lit Protocol 解密](https://relationlabs.gitbook.io/relation-graph/g-zh/guide/use-litprotocol-to-decrypt)。
* Header

| Field  | Type   | Required | Remarks                                                                                                   |
| ------ | ------ | -------- | --------------------------------------------------------------------------------------------------------- |
| ApiKey | String | true     | 从管理员获取的 [ApiKey](https://relationlabs.gitbook.io/relation-graph/g-zh/api/cross-platform-identity-linking) |

* Request Parameters

| Field           | Type   | Required | Remarks                                                                                                                                                                    |
| --------------- | ------ | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| address         | String | fasle    | EOA Address                                                                                                                                                                |
| twitterUsername | String | fasle    | twitter username                                                                                                                                                           |
| steamId         | String | fasle    | steamId                                                                                                                                                                    |
| sig             | String | true     | 用户授权信息签名（签名可参考[SIWE](https://docs.login.xyz/),带有授权信息时，开发者可[使用 Lit Protocol 对返回结果解密](https://relationlabs.gitbook.io/relation-graph/g-zh/guide/use-litprotocol-to-decrypt)） |
| message         | String | true     | 用户授权信息签名原文（签名原文拼接可参考[SIWE](https://docs.login.xyz/),其中statement字段需要为:**Access to Secure Cross-Platform Identity Linking.**)）                                               |

* Request Example

```shell
curl  GET 'https://api.relationlabs.ai/api/v1/crossPlatformIdentityLinking?address=0x9bd286ef4e3d9ec1af6c6ae9da2f0b3617deab13&sig=0x001111&message=example.com%20wants%20you%20to%20sign%20in%20with...' \
--header 'ApiKey: <ApiKey>'
```

* Response Parameters

| Field | Type          | Remarks                               |
| ----- | ------------- | ------------------------------------- |
| code  | String        | 返回码                                   |
| desc  | String        | 返回信息                                  |
| data  | EncryptedData | 使用 Lit Protocol 加密过的Tag数据，需要向用户申请授权解密 |

EncryptedData解密后的字段如下:

| Field    | Type     | Remarks    |
| -------- | -------- | ---------- |
| relation | Relation | Relation信息 |
| address  | List     | 地址列表       |
| twitter  | Twitter  | 推特信息       |
| steam    | Steam    | steam信息    |

EncryptedData解密后的数据结构

```json
{
  "code": "0",
  "desc": "success",
  "data": {
    "address": [],
    "relation": {
      "relationId": "d4swz-zaaaa-aaaaj-at5fa-cai",
      "name": "test_user",
      "avatar": "https://3fypb-gqaaa-aaaag-aaedq-cai.ic1.io/nft/eth/relation-test-club/16.png"
    },
    "twitter": {
      "username": "VitalikButerin",
      "name": "vitalik.eth",
      "avatar": "https://pbs.twimg.com/profile_images/977496875887558661/L86xyLF4_400x400.jpg"
    },
    "steam": {
      "steamId": "178691028912",
      "name": "vitalik",
      "avatar": "https://pbs.twimg.com/profile_images/977496875887558661/L86xyLF4_400x400.jpg"
    }
  }
}
```

* Response Body

```json
{
  "code": "0",
  "desc": "success",
  "data": {
    "encryptedString": "xxx",
    "encryptedSymmetricKey": "xxx"
  }
}
```

* Return Code

| code | desc    | Remarks                           |
| ---- | ------- | --------------------------------- |
| 0    | success | the flag for a successful request |
