# Introducing MID

Experience the synergy of a truly interlinked digital world with MID

MID is a decentralized identity protocol developed by ManesLAB. It forms the foundational product of the entire ManesLAB ecosystem. The current version of MID offers functionalities such as binding multiple blockchain wallet addresses under a single name and linking with mainstream social media accounts. It is the first step for users to construct their own social relation graphs. Moreover, MID can also serve as a login module to bridge the data islands of various websites and apps.

## Minimal Limitations, Maximum Features&#x20;

For login, MID users can either use their bound wallets for Web3 wallet signature login, or register and login through traditional means like email, catering to both Web2 & Web3 users. The operational experience is smooth, with extremely low barriers to entry. This effectively satisfies users' diverse needs, such as asset queries, asset displays, asset calls, authority services, and identity verification across multiple chains.

## Robust Protocol, Lean Application&#x20;

As the foundation of the ManesLAB ecosystem, MID provides support for the accelerated development and efficient collaboration within the ecosystem. Based on MID, ManesLAB will offer various resource support to ecosystem partners and reciprocate the potential captured by the protocol to all partners, fostering a positive cycle for the rapid development of the ecosystem.

## **Small Steps, Great Potential**

Regarding feature iteration, MID has already taken firm steps to meet user requirements in areas such as security, information privacy, identity verification, asset recognition, user profiling, customer relationship management, and brand marketing. It caters to both B2C and B2B needs, committed to building a lower-cost, higher-efficiency, and safer identity data network. In the future, MID will gradually cover more scenes via web apps, mobile apps, and smart interactive apps. By leveraging the real-time, embedded, and extensible advantages of blockchain technology and foundational application protocols, it provides a smooth, traceable, and efficient O2O (Online to Offline) service for more Web2 & Web3 users, guiding the deep integration of the Web2 & Web3 ecosystem.

## Short Path, Long Cycle&#x20;

While Web3 mass adoption is a long journey, MID aims to add a long-term foundational strength to Web3 building through continuous development and exploration of this shortest path. It assists more individuals, organizations, and brands to play their unique advantages, merge into the diverse Web3 ecosystem, protect their asset security, and find the next growth point in multiple fields.

## **Initiated by Applications, Perfected by Protocols**

As an ever-evolving foundational protocol, MID's short-term goal is to guide millions of Web2 users into the corresponding Web3 service ecosystem. In the long run, it aspires to lead billions of Web2 users to deeply enjoy the dividends of the Web3 ecosystem, and to become one of the most mature foundational infrastructure applications in the Web3 field.


# How .mid works

.mid is a large-scale, universally readable identity service network developed based on MID (Multi-chain Identity, a user multi-chain wallet on-chain asset authentication application protocol). The format suffix is .mid, and the initial registration status defaults to an 8-digit random numeric string. After users set a unique exclusive name and claim it for free (note: unmodifiable after registration), it will serve as their Web3 exclusive identity system identifier. Its specific on-chain form is an SBT (SoulBound Token) and is used for various purposes, such as on-chain identity recognition, social identity display, ecosystem reputation accumulation, and scenario-based consumption incentives. Unlike traditional methods that restrict character languages and symbols, .mid imposes no restrictions on users, allowing them to freely choose their preferred language, thus offering more possibilities for personalized display.

.mid serves as a Layer 2 network in the Web3 identity system, becoming a more intuitive identity image symbol based on MID. It will bridge the isolation between SBT and DID (Decentralized Identity), becoming a versatile application that accommodates single-use scenarios, different operational statuses, and on-chain panoramic displays.

The goal of .mid is to become the window bridging Web2 & Web3 users with the rich Web3 ecosystem, fostering interactive relationships. Through this, it aims to strengthen the Web3 identity authentication security system, guide efficient interaction for Web3 individual brands, and create a new breakthrough for large-scale applications in the Web3 ecosystem.


# Partners

Partners


# CutUp


# How CutUp Receipt NFT works

CutUp is an emerging fashion brand and one of MID's initial partners.

After users complete a shopping process on CutUp, MID will mint an uniqle digital receipt on the Polygon blockchain. Using the immutable nature of blockchain, data is permanently stored after being anonymized. This digital receipt captures a unique shopping experience on CutUp, serving as a special digital collectible for users.

For CutUp users without a digital wallet, MID offers a digital asset custody service. Users need to bind at least one EVM-compatible wallet in MID. Only then can we send the digital receipt to the user's wallet. If users don't yet have a wallet, MID will temporarily store it for them. Receiving this digital receipt is entirely free for users, the blockchain gas fee is covered by MID.

You can visit [MID's official website](https://mid.maneslab.xyz) for more details about wallet binding.

We advocate for compliant use of digital assets and strictly adhere to local laws and regulations. We hope this document helps you understand how MID's digital collectible issuance works, ensuring a convenient and safe experience for your digital assets.

Using our digital service indicates your awareness and agreement with MID's [Term of Service](https://mid.maneslab.xyz/legal/terms) and [Privacy Policy](https://mid.maneslab.xyz/legal/privacy).


# How CutUp Digital Voucher works

CutUp is an emerging fashion brand and among the first to partner with MID, integrating the MID account system.&#x20;

By completing specific quests on social media accounts linked with MID, such as following or sharing content, or holding particular digital assets in their MID-linked wallets, CutUp users can earn digital vouchers. These vouchers are automatically applied during checkout for discounts.

You can visit [MID's official website](https://mid.maneslab.xyz) for more details about wallet binding.

We advocate for compliant use of digital assets and strictly adhere to local laws and regulations. We hope this document helps you understand how MID's digital collectible issuance works, ensuring a convenient and safe experience for your digital assets.

Using our digital service indicates your awareness and agreement with MID's [Term of Service](https://mid.maneslab.xyz/legal/terms) and [Privacy Policy](https://mid.maneslab.xyz/legal/privacy).


# API Integration

For integrating MID into your service, kindly request an API key by reaching out to us at <gm@maneslab.xyz>


# Quick start

MID is a powerful tool that allows developers to connect their applications to the MID platform using Oauth2 authentication. With the MID API, developers can easily integrate their applications with MID's vast array of features, including get user profile, get wallets information, and get NFT information.\
\
For integrating MID into your service, kindly request an API key by reaching out to us at <gm@maneslab.xyz>

### Web application flow

The web application flow to authorize users for your app is:

1. Users are directed to MID authorization to [request their MID identity](/api-integration/quick-start/1.-request-a-users-mid-identity)
2. Users approve and [redirected back to your site ](/api-integration/quick-start/2.-redirect-back-to-your-site-by-mid)by MID
3. Your app now can [access user information](/api-integration/quick-start/3.-use-the-access-token-to-access-the-api) through MID API with the user's access token


# 1. Request a user's MID identity

```
GET https://mid.maneslab.xyz/oauth/authorize
```

#### Parameters:

| Parameter name | Type   | Description                                                                                              |
| -------------- | ------ | -------------------------------------------------------------------------------------------------------- |
| response\_type | string | Required. response\_type=code                                                                            |
| client\_id     | string | Required. The client ID you received from MID.                                                           |
| redirect\_uri  | string | Required. The URL in your application where users will be sent after authorization.                      |
| scope          | string | Required.scope=profile                                                                                   |
| state          | string | Required.An unguessable random string. It is used to protect against cross-site request forgery attacks. |


# 2. Redirect back to your site by MID

If the user accepts your request, MID redirects the user back to your site with a temporary **`code`** in a code parameter. The temporary code will expire after 10 minutes.&#x20;

In addition, it also contains the state you provided in the previous step in the **`state`** parameter. If the states don't match, it means a third party created the request, and you should abort the process.

Exchange the code for an access token:

```HTTP
POST https://mid.maneslab.xyz/api/v1/oauth/token
```

#### Parameters:

<table><thead><tr><th width="210.33333333333331">Parameter name</th><th width="182">Type</th><th>Description</th></tr></thead><tbody><tr><td>client_id</td><td>string</td><td>Required. The client ID you received from MID for your OAuth App.</td></tr><tr><td>client_secret</td><td>string</td><td>Required. The client secret you received from MID for your OAuth App.</td></tr><tr><td>grant_type</td><td>string</td><td>Required. grant_type=authorization_code</td></tr><tr><td>code</td><td>string</td><td>Required. The code you received as a response to Step 1.</td></tr><tr><td>redirect_uri</td><td>string</td><td>Required. The URL in your application where users are sent after authorization.</td></tr></tbody></table>

sample code:

```
let data = {
    'client_id': client_id,
    'client_secret': client_secret,
    'grant_type': 'authorization_code',
    'code': code,
    'redirect_uri': redirect_uri,
};

let form_body = [];
for (let property in data) {
    let encoded_key = encodeURIComponent(property);
    let encoded_value = encodeURIComponent(data[property]);
    form_body.push(encoded_key + "=" + encoded_value);
}
form_body = form_body.join("&");

let options = {
    method: 'POST',
    headers: {
        "content-type": "application/x-www-form-urlencoded",
    },
    body: form_body
};

fetch(`https://mid.maneslab.xyz/api/v1/oauth/token`, options)
    .then(response => response.json())
    .then(response => {
        console.log(response)
    })
    .catch(err => console.error(err));
```

Example responses:

```JSON
{
  "access_token":"xxxxxxxx",
  "token_type":"bearer"
}
```


# 3. Use the access token to access the API

The access token allows you to make requests to the API on a behalf of a user.

<pre class="language-HTTP"><code class="lang-HTTP"><strong>Authorization: Bearer OAUTH-TOKEN
</strong>GET https://mid.maneslab.xyz/api/v1/users/me
</code></pre>

For example, you can set the Authorization header like this:

```HTTP
curl -H "Authorization: Bearer OAUTH-TOKEN" https://mid.maneslab.xyz/api/v1/users/me
```


# API


# GET users/me

### **Endpoint URL**

```
https://mid.maneslab.xyz/api/v1/users/me
```

### **OAuth 2.0 scopes required**

profile

### Sample code:

```
let options = {
    method: 'Get',
    headers: {
        "authorization": `Bearer ${OAUTH-TOKEN}`,
        "content-type": "application/x-www-form-urlencoded",
    },
};
fetch('https://mid.maneslab.xyz/api/v1/users/me', options)
    .then(response => response.json())
    .then(response => {
        console.log(response)
    })
    .catch(err => console.error(err));
```

### **Example response**

```JSON
{
  "email":"account@maneslab.xyz",
  "id":"3109a9d0aaea49999e2d48e0bca8407b",
  "avatar":"https://xxxx",
  "mid":"66666"
}
```


# GET wallets

Get authorized user's wallets info.

### **Endpoint URL**

```
https://mid.maneslab.xyz/api/v1/wallets
```

### **OAuth 2.0 scopes required by this endpoint**

profile

### Sample code

```
let options = {
    method: 'Get',
    headers: {
        "authorization": `Bearer ${OAUTH-TOKEN}`,
        "content-type": "application/x-www-form-urlencoded",
    },
};
fetch('https://mid.maneslab.xyz/api/v1/wallets', options)
    .then(response => response.json())
    .then(response => {
        console.log(response)
    })
    .catch(err => console.error(err));
```

### **Example response**

```JSON
[
    {
      "id":"6406e0b96950c2aafa2056ca",
      "address":"xxxxxxxx",
      "chain":{
          "chain_id":"1",
          "name" : "Ethereum"
      },
      "name":"wallet1"
    },
    ...
]
```


# GET NFTs

Get authorized user's NFTs.

### **Endpoint URL**

```
https://mid.maneslab.xyz/api/v1/nfts
```

### **OAuth 2.0 scopes required by this endpoint**

profile

### Sample code

```
let options = {
    method: 'Get',
    headers: {
        "authorization": `Bearer ${OAUTH-TOKEN}`,
        "content-type": "application/x-www-form-urlencoded",
    },
};
fetch('https://mid.maneslab.xyz/api/v1/nfts', options)
    .then(response => response.json())
    .then(response => {
        console.log(response)
    })
    .catch(err => console.error(err));
```

### **Example responses**

```JSON
[
  {
    "owner_address": "0x06cFfBB08ccBC010a50638aa298CCd5C013c08C6",
    "chain": "ethereum",
    "name": "Lil Ghost#0",
    "token_id": "0",
    "image_url": "https://cdn.simplehash.com/assets/95a1090d26c5a1765863a3f0c6462c5c280386a8a5adbebb8c67b8b7b88c76d5.png",
    "collection_name": "The Weirdo Ghost Gang",
    "contract_address": "0x9401518f4ebba857baa879d9f76e1cc8b31ed197"
  },
  ...
]
```


# MID 的愿景

与 MID 一起，感受数字世界的互联协同效应

MID是一个由 ManesLAB 开发的数字身份协议，是ManesLAB 整体生态最底层产品。 ​目前版本的 MID 提供了绑定归集名下的多链钱包地址及主流社交媒体账号的功能，是用户构筑属于自己的社交关系图谱的第一步。同时，MID 也可作为登录模块，将各个网站、应用的数据孤岛打通。

## **少限制，多功能**&#x20;

登录选择方面，MID 用户既可通过已绑定钱包进行 Web3 钱包签名登录，也可以通过邮箱等传统方式注册登陆，面向 Web2 & Web3 全量用户，操作体验顺滑，使用门槛极低，有效满足用户基于多链使用场景的资产查询、资产展示、资产调用、权限服务以及身份认证等多重需求。

## **胖协议，瘦应用**&#x20;

作为 ManesLAB 生态的最底层，MID 将为整个生态的增速发展与生态内应用高效协同提供支持。基于 MID，ManesLAB 将为生态伙伴提供各类资源支持，并将协议捕获的势能反哺给所有生态伙伴，形成生态快速发展的正向循环。

## **小切口，大未来**

功能迭代方面，目前 MID 已经在满足用户安全、信息隐私、身份认证、资产识别、用户画像、客户关系管理、品牌市场营销等方面迈出坚实一步，满足 To C、 To B 的双向需求，着力建设一个更为低成本、高效率、强安全、正相关的身份数据网络。未来，MID 还将通过网页应用、移动应用、智能交互应用等多个端口，逐渐覆盖更多重场景，发挥区块链技术与底层应用型协议的强即时性、强嵌入性、强扩展性优势，为更多的 Web2 & Web3 用户提供顺滑无感、溯源存证、便捷高效的 O2O （Online to Offiline）服务，引导 Web2 & Web3 生态深度融合。

## **短路径，长周期**&#x20;

Web3 Mass Adoption 任重道远，但 MID 希望通过这一最短路径不断地发展与探索为 Web3 生态建设增添一份长期的基底性力量，助力更多个体、组织、品牌发挥自身独特优势，融入 Web3 多元化生态，保护自身资产安全，寻找多领域发展的下一个增长点。

## **始于应用，成于协议**

作为不断发展完善的底层协议，MID 的短期目标着眼于引导百万 Web2 用户进入 Web3 对应生态服务体系，长期目标则立志带领十亿 Web2 用户深度享受 Web3 生态红利，成为 Web3 领域最为成熟的底层基础设施建设应用之一。


# MID 操作指南


# 1️⃣ 创建 MID 账户

1. 您可参考以下流程创建 MID 账户。

<figure><img src="https://2054235730-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfafOfwfoKUgfs0nlb5Ej%2Fuploads%2FPCOJ2pbB41xlTFwf0DdE%2FMID_Account%20Creation%20(1).gif?alt=media&amp;token=d77a34dc-40d7-4ab8-9cbf-2121f19e3194" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
您的密码必须包含至少一位特殊符号以及大写字母。
{% endhint %}

2. 我们强烈建议您在完成账户注册后，前往 个人中心 - 设置 - 两步验证，添加两步验证已提高账户安全性。

{% hint style="success" %}
中国大陆用户亦可使用Microsoft Authenticator或腾讯身份验证小程序替代谷歌两步验证器，扫码二维码并保存备份代码即可。
{% endhint %}

<figure><img src="https://2054235730-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfafOfwfoKUgfs0nlb5Ej%2Fuploads%2FpuUp9ThUaG4T3FGne2iP%2Fimage.png?alt=media&amp;token=db204687-b0ae-4645-adbd-843fdce5ea6c" alt=""><figcaption></figcaption></figure>


# 2️⃣ 绑定数字钱包

1. 前往 个人中心 - 我的钱包，点击 添加新钱包，在 Web3 组件弹窗中选择您使用的对应钱包，在弹出的浏览器钱包插件中确认签名即可。

<figure><img src="https://2054235730-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfafOfwfoKUgfs0nlb5Ej%2Fuploads%2FVGYg35CaxCGZrbIjIIuF%2FConnect%20Wallet%201.gif?alt=media&amp;token=43fd0bf6-54a8-4353-bfcc-331dad8a0177" alt=""><figcaption></figcaption></figure>

2. 您可继续在其他设备，或是通过切换浏览器钱包中的账户地址，在同一 MID 账户中绑定多个数字钱包地址。

<figure><img src="https://2054235730-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfafOfwfoKUgfs0nlb5Ej%2Fuploads%2FMNEn88tF9jLDXvkzINyS%2FConnect%20Multiple%20Wallet.gif?alt=media&amp;token=071b9a82-31fd-4286-8d5e-2e73ed6fe36f" alt=""><figcaption></figcaption></figure>

3. 您可使用备注功能，为已绑定钱包设置备注名。

<figure><img src="https://2054235730-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfafOfwfoKUgfs0nlb5Ej%2Fuploads%2FwJ0Fja2RlCYkM76yXqpX%2FWallet%20Note.gif?alt=media&amp;token=5be6cd8b-f2ef-47ee-bfa9-7032ce7df7e6" alt=""><figcaption></figcaption></figure>

4. 完成钱包绑定连接后，您可以使用任意一个已绑定钱包，通过 Web3 签名登录的方式，免密登录 MID。

<figure><img src="https://2054235730-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfafOfwfoKUgfs0nlb5Ej%2Fuploads%2FMJhnJpiKXF719EcOJuOX%2FWeb3%20Log%20in.gif?alt=media&amp;token=133dd379-a438-4a03-9697-35df64204bcf" alt=""><figcaption></figcaption></figure>

5. 出于账户安全考量，在移除已绑定账户时，MID 会向您发送验证邮件。如果您已经绑定2FA两步验证，MID 则会要求您输入谷歌两步验证码。

{% hint style="warning" %}
当您确认或怀疑某一个绑定钱包私钥或助记词已泄露，请立即前往 MID 解绑。即使攻击者可能无法移除您的其他账号以及修改密码，攻击者仍然可以通过泄露的钱包地址登录您的 MID。
{% endhint %}

<figure><img src="https://2054235730-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfafOfwfoKUgfs0nlb5Ej%2Fuploads%2FI5BqnI6H5XA56NFyy0CT%2Fwallet%20remove.gif?alt=media&amp;token=646ec8b3-9408-4c44-a5e1-9f7e2e9515e2" alt=""><figcaption></figcaption></figure>


# 3️⃣ 免费领取 .mid 身份

.mid 是基于 MID （Multi-chain Identity, 用户多链钱包链上资产认证应用型协议）开发的一个大型通用可读身份服务网络，格式后缀为 .mid。您可在[此文档](/zh/liao-jie-.mid-de-gong-zuo-yuan-li)中了解更多关于 .mid 的信息。\
\
完成 MID 账户注册后，您可以按照以下步骤领取 .mid 身份。

{% hint style="info" %}
.mid 身份领取后将无法修改。
{% endhint %}

<figure><img src="https://2054235730-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfafOfwfoKUgfs0nlb5Ej%2Fuploads%2FweelKRVXQ2uIakdKL5pA%2Fclaim%20MID.gif?alt=media&amp;token=d8bdb777-5b32-46ad-bcd3-856bc7f0182d" alt=""><figcaption></figcaption></figure>


# 了解 .mid 的工作原理

.mid 是基于 MID （Multi-chain Identity, 用户多链钱包链上资产认证应用型协议）开发的一个大型通用可读身份服务网络，格式后缀为 .mid, 初始注册状态默认为8位数随机数字串，在用户设置独一无二的专属名称并免费 claim 之后（注：注册后无法修改），将作为用户 Web3 专属身份系统标识存在，具体链上形态为 SBT（SoulBound Token, 灵魂绑定**通证**），服务于链上身份识别、社交身份展示、生态信誉积累、场景消费激励等多样目的。与传统的限制字符语言和符号的方式不同，.mid不会对用户做任何限制，用户可以自由选择自己喜欢的语言，从而为您的个性化展示带来更多可能性。<br>

.mid 将作为 Web3 身份标识体系中的 Layer 2 网络，在 MID 的基础上成为更直观的身份形象说明符号，打通 SBT 与 DID（Decentralized Identity, 去中心化身份）之间的孤立隔绝状态，成为兼顾单一使用场景、不同操作状态与链上全景展示的多重应用。<br>

.mid 的目标是成为连接 Web2 & Web3 人群与 Web3 丰富生态产生交互关系的第一个窗口，借此强化 Web3 身份认证安全体系、引导 Web3 个体品牌高效互动、创造 Web3 生态大规模应用全新突破口。


# 合作伙伴


# CutUp

CutUp


# 了解 CutUp 数字代金券的工作原理

CutUp 是一家新兴的潮流品牌，作为 MID 首批合作伙伴之一，接入了 MID 账户体系。CutUp 用户通过使用在 MID 绑定的社交账号完成特定任务（如关注或转发社交媒体内容），或在 MID 中绑定的钱包持有特定数字资产（如数字作品），即可获得 CutUp 数字代金券并在购物流程结算时自动减免，享受价格优惠。

您可前往 MID 的[官方网站](https://mid.maneslab.xyz)，完成钱包绑定以及授权步骤，并了解关于钱包绑定及数字作品授权的详细信息。

我们重视数字资产的合规使用，并严格遵守所在地相关法律法规。希望本文能够帮助您更好地了解MID账户体系的延展性和更多可能性。&#x20;

使用数字代金券，意味您知悉并同意 MID 的[服务条款](https://mid.maneslab.xyz/legal/terms)及[隐私政策](https://mid.maneslab.xyz/legal/privacy)


# 了解 CutUp 数字小票的工作原理

CutUp 是一家新兴的潮流品牌，也是 MID 首批合作伙伴之一。 用户在 CutUp 完成购物流程后，MID 将会在 Polygon 区块链上铸造出一张用户不可自主转移的数字小票，利用区块链数字作品不可篡改的特性，将脱敏后的数据永久保存于区块链之上。数字小票记载着 CutUp 用户独一无二的购物经历，也将成为一份专属于用户的珍贵数字收藏品。

对于尚未拥有数字钱包的 CutUp 用户，MID 还为 CutUp 提供了数字资产托管服务，用户需要在 MID 中完成至少一个 EVM 兼容链钱包绑定后，我们才可以将数字小票发送至用户的钱包中，如果用户暂时未拥有数字钱包，MID会帮助用户临时存储保管。数字小票的接受对用户完全免费，所有的区块链燃料费用由 MID 承担。

您可前往 MID [官方网站](https://mid.maneslab.xyz)，了解关于钱包绑定的详细信息。

我们主张以合规的方式使用数字资产，并严格遵守所在地相关法律法规。希望本文能够帮助您更好地了解MID数字藏品发行的工作原理，并为您的数字作品定制体验提供便捷和安全的保障。

使用数字代金券，意味您知悉并同意 MID 的[服务条款](https://mid.maneslab.xyz/legal/terms)及[隐私政策](https://mid.maneslab.xyz/legal/privacy)


# CutUp 城市派对地图小程序

MID 的合作伙伴 CutUp 于2023年9月推出「城市派对地图小程序」，届时将为所有参与者发放包含衣食住行各方面的限定版数字优惠券。

## 优惠券类型

1. 普通优惠券：无门槛，所有参与者均可领取
2. <mark style="color:blue;">Web3er优惠券</mark>：在 MID 中绑定持有任意 NFT 的数字钱包，并授权登录 CutUp
3. <mark style="color:yellow;">幽灵优惠券</mark>：在 MID 中绑定持有 Weirdo Ghost Gang 小幽灵的数字钱包，并授权登录 CutUp

## 如何绑定 MID 以解锁 Web3er/幽灵优惠券

如果您是 Web3 藏家，想在在小程序中领取使用 <mark style="color:blue;">Web3er优惠券</mark> 或 <mark style="color:yellow;">幽灵优惠券</mark>，您需要通过连接 MID 授权以检查是否满足领取条件。您可根据以下四种场景完成 MID 授权绑定:&#x20;

{% hint style="success" %}
为了更好的钱包绑定体验，我们建议您在 MID 桌面网页端进行钱包绑定操作。
{% endhint %}

### 场景A: 暂无 CutUp 账号，暂无 MID 账号

1. 前往 [CutUp官网](https://cutup.store/home) 使用邮箱注册账号 &#x20;
2. 随后前往 [MID官网](https://mid.maneslab.xyz/) 使用与 CutUp 账户相同的邮箱注册 MID 账号 ，可参考使用指南 [「创建MID账户」](https://docs.maneslab.xyz/v/zh/shi-yong-jiao-cheng/1-chuang-jian-mid-zhang-hu)以及[「绑定数字钱包教程」](https://docs.maneslab.xyz/v/zh/shi-yong-jiao-cheng/2-bang-ding-shu-zi-qian-bao)绑定数字钱包
3. 前往 「小程序」 - 「使用邮箱登录」，或者在「微信快捷登录」后绑定 CutUp 账户

为了更好的钱包绑定体验，我们建议您在桌面网页端进行钱包绑定操作。

***

### 场景B: 暂无 CutUp 账号，已有 MID 账号

1. 确保您在 MID 中已经绑定数字钱包，可参考操作指南 [「绑定数字钱包教程」](https://docs.maneslab.xyz/v/zh/shi-yong-jiao-cheng/2-bang-ding-shu-zi-qian-bao)
2. 前往 「小程序」 - 「微信快捷登录」 - 不绑定
3. 前往 「账户」 - 「绑定 MID」，在登录页登录 MID

***

### 场景C: 已有 CutUp 账号，暂无 MID 账号

1. 前往 [MID官网](https://mid.maneslab.xyz/) 使用与 CutUp 账户相同的邮箱注册 MID 账号 ，可参考使用指南 [「创建MID账户」](https://docs.maneslab.xyz/v/zh/shi-yong-jiao-cheng/1-chuang-jian-mid-zhang-hu)以及[「绑定数字钱包教程」](https://docs.maneslab.xyz/v/zh/shi-yong-jiao-cheng/2-bang-ding-shu-zi-qian-bao)绑定数字钱包
2. 前往「小程序」 - 「使用邮箱登录」，或者在「微信快捷登录」后绑定 CutUp 账户

{% hint style="info" %}
如果您的 CutUp 账户通过 MID 授权登录创建，您可能并不清楚您 CutUp 账户的密码。\
此时可在 CutUp 官网通过「找回密码」的方式重置密码。
{% endhint %}

{% hint style="warning" %}
如您选择微信快捷登录，且已有 CutUp 账号，请务必在小程序内完成 CutUp 账号绑定步骤。否则新创建账户无法与您的旧账户进行合并。
{% endhint %}

***

### 场景D: 已有 CutUp 账号，已有 MID 账号

1. 确保您在 MID 中已经绑定数字钱包，可参考操作指南 [「绑定数字钱包教程」](https://docs.maneslab.xyz/v/zh/shi-yong-jiao-cheng/2-bang-ding-shu-zi-qian-bao)
2. 前往「小程序」 - 「使用邮箱登录」，或者在「微信快捷登录」后绑定 CutUp 账户

{% hint style="info" %}
如果您的 CutUp 账户通过 MID 授权登录创建，您可能并不清楚您 CutUp 账户的密码。\
此时可在 CutUp 官网通过「找回密码」的方式重置密码。
{% endhint %}

{% hint style="warning" %}
如您选择微信快捷登录，且已有 CutUp 账号，请务必在小程序内完成 CutUp 账号绑定步骤。否则新创建账户无法与您的旧账户进行合并。
{% endhint %}

## 已完成绑定，但是在个人主页没有看到 MID 数据更新？

请在「账户」页面下拉刷新即可。


# API 整合

若要将 MID 集成到您的服务中，请通过联系我们的邮箱 <gm@maneslab.xyz> 来请求 API 密钥。


# Quick start

MID is a powerful tool that allows developers to connect their applications to the MID platform using Oauth2 authentication. With the MID API, developers can easily integrate their applications with MID's vast array of features, including get user profile, get wallets information, and get NFT information.\
\
For integrating MID into your service, kindly request an API key by reaching out to us at <gm@maneslab.xyz>

### Web application flow

The web application flow to authorize users for your app is:

1. Users are directed to MID authorization to [request their MID identity](/zh/api-zheng-he/quick-start/1.-request-a-users-mid-identity)
2. Users approve and [redirected back to your site ](/zh/api-zheng-he/quick-start/2.-redirect-back-to-your-site-by-mid)by MID
3. Your app now can [access user information](/zh/api-zheng-he/quick-start/3.-use-the-access-token-to-access-the-api) through MID API with the user's access token


# 1. Request a user's MID identity

```
GET https://mid.maneslab.xyz/oauth/authorize
```

#### Parameters:

| Parameter name | Type   | Description                                                                                              |
| -------------- | ------ | -------------------------------------------------------------------------------------------------------- |
| response\_type | string | Required. response\_type=code                                                                            |
| client\_id     | string | Required. The client ID you received from MID.                                                           |
| redirect\_uri  | string | Required. The URL in your application where users will be sent after authorization.                      |
| scope          | string | Required.scope=profile                                                                                   |
| state          | string | Required.An unguessable random string. It is used to protect against cross-site request forgery attacks. |


# 2. Redirect back to your site by MID

If the user accepts your request, MID redirects the user back to your site with a temporary **`code`** in a code parameter. The temporary code will expire after 10 minutes.&#x20;

In addition, it also contains the state you provided in the previous step in the **`state`** parameter. If the states don't match, it means a third party created the request, and you should abort the process.

Exchange the code for an access token:

```HTTP
POST https://mid.maneslab.xyz/api/v1/oauth/token
```

#### Parameters:

<table><thead><tr><th width="210.33333333333331">Parameter name</th><th width="182">Type</th><th>Description</th></tr></thead><tbody><tr><td>client_id</td><td>string</td><td>Required. The client ID you received from MID for your OAuth App.</td></tr><tr><td>client_secret</td><td>string</td><td>Required. The client secret you received from MID for your OAuth App.</td></tr><tr><td>grant_type</td><td>string</td><td>Required. grant_type=authorization_code</td></tr><tr><td>code</td><td>string</td><td>Required. The code you received as a response to Step 1.</td></tr><tr><td>redirect_uri</td><td>string</td><td>Required. The URL in your application where users are sent after authorization.</td></tr></tbody></table>

sample code:

```
let data = {
    'client_id': client_id,
    'client_secret': client_secret,
    'grant_type': 'authorization_code',
    'code': code,
    'redirect_uri': redirect_uri,
};

let form_body = [];
for (let property in data) {
    let encoded_key = encodeURIComponent(property);
    let encoded_value = encodeURIComponent(data[property]);
    form_body.push(encoded_key + "=" + encoded_value);
}
form_body = form_body.join("&");

let options = {
    method: 'POST',
    headers: {
        "content-type": "application/x-www-form-urlencoded",
    },
    body: form_body
};

fetch(`https://mid.maneslab.xyz/api/v1/oauth/token`, options)
    .then(response => response.json())
    .then(response => {
        console.log(response)
    })
    .catch(err => console.error(err));
```

Example responses:

```JSON
{
  "access_token":"xxxxxxxx",
  "token_type":"bearer"
}
```


# 3. Use the access token to access the API

The access token allows you to make requests to the API on a behalf of a user.

<pre class="language-HTTP"><code class="lang-HTTP"><strong>Authorization: Bearer OAUTH-TOKEN
</strong>GET https://mid.maneslab.xyz/api/v1/users/me
</code></pre>

For example, you can set the Authorization header like this:

```HTTP
curl -H "Authorization: Bearer OAUTH-TOKEN" https://mid.maneslab.xyz/api/v1/users/me
```


# API


# GET users/me

### **Endpoint URL**

```
https://mid.maneslab.xyz/api/v1/users/me
```

### **OAuth 2.0 scopes required**

profile

### Sample code:

```
let options = {
    method: 'Get',
    headers: {
        "authorization": `Bearer ${OAUTH-TOKEN}`,
        "content-type": "application/x-www-form-urlencoded",
    },
};
fetch('https://mid.maneslab.xyz/api/v1/users/me', options)
    .then(response => response.json())
    .then(response => {
        console.log(response)
    })
    .catch(err => console.error(err));
```

### **Example response**

```JSON
{
  "email":"account@maneslab.xyz",
  "id":"3109a9d0aaea49999e2d48e0bca8407b",
  "avatar":"https://xxxx",
  "mid":"66666"
}
```


# GET wallets

Get authorized user's wallets info.

### **Endpoint URL**

```
https://mid.maneslab.xyz/api/v1/wallets
```

### **OAuth 2.0 scopes required by this endpoint**

profile

### Sample code

```
let options = {
    method: 'Get',
    headers: {
        "authorization": `Bearer ${OAUTH-TOKEN}`,
        "content-type": "application/x-www-form-urlencoded",
    },
};
fetch('https://mid.maneslab.xyz/api/v1/wallets', options)
    .then(response => response.json())
    .then(response => {
        console.log(response)
    })
    .catch(err => console.error(err));
```

### **Example response**

```JSON
[
    {
      "id":"6406e0b96950c2aafa2056ca",
      "address":"xxxxxxxx",
      "chain":{
          "chain_id":"1",
          "name" : "Ethereum"
      },
      "name":"wallet1"
    },
    ...
]
```


# GET NFTs

Get authorized user's NFTs.

### **Endpoint URL**

```
https://mid.maneslab.xyz/api/v1/nfts
```

### **OAuth 2.0 scopes required by this endpoint**

profile

### Sample code

```
let options = {
    method: 'Get',
    headers: {
        "authorization": `Bearer ${OAUTH-TOKEN}`,
        "content-type": "application/x-www-form-urlencoded",
    },
};
fetch('https://mid.maneslab.xyz/api/v1/nfts', options)
    .then(response => response.json())
    .then(response => {
        console.log(response)
    })
    .catch(err => console.error(err));
```

### **Example responses**

```JSON
[
  {
    "owner_address": "0x06cFfBB08ccBC010a50638aa298CCd5C013c08C6",
    "chain": "ethereum",
    "name": "Lil Ghost#0",
    "token_id": "0",
    "image_url": "https://cdn.simplehash.com/assets/95a1090d26c5a1765863a3f0c6462c5c280386a8a5adbebb8c67b8b7b88c76d5.png",
    "collection_name": "The Weirdo Ghost Gang",
    "contract_address": "0x9401518f4ebba857baa879d9f76e1cc8b31ed197"
  },
  ...
]
```


