# 4. Get verification info

Use the **`imp_uid`** obtained from mobile identity verification to get the customer's verification information.

### <mark style="color:blue;">**STEP 01.**</mark> Get verification ID (imp\_uid) on the server-side

The following server-side code fetches the data returned from mobile identity verification.

{% tabs %}
{% tab title="Node.js (popup)" %}
{% code title="server-side" %}

```javascript
app.use(bodyParser.json());
  ...
  // controller that handles POST request to "/certifications"
  app.post("/certifications", async (request, response) => {
    const { imp_uid } = request.body; // Get imp_uid from req.body
})

```

{% endcode %}
{% endtab %}

{% tab title="Node.js (redirection)" %}

<pre class="language-javascript" data-title="server-side"><code class="lang-javascript">app.use(bodyParser.json());
  ...
<strong>  // controller that handles GET request to "/certifications/redirect"
</strong>  app.get("/certifications/redirect", async (request, response) => {
    const { imp_uid } = request.query; // Get imp_uid from req.query
})
</code></pre>

{% endtab %}
{% endtabs %}

### <mark style="color:blue;">**STEP 02.**</mark> Get verification information

To get verification information from the i'mport server, you must first get a [**REST API access token**](https://portone.gitbook.io/docs-en/api/rest-api-access-token). Use the `access token` and `imp_uid` (verification ID) to call the <mark style="color:blue;">**Get identity verification info REST API**</mark> that returns the verification information as follows:

{% code title="sever-side" %}

```javascript
app.use(bodyParser.json());
  ...
  // controller that handles POST request to "/certifications"
  app.post("/certifications", async (request, response) => {
    const { imp_uid } = request.body; // Get imp_uid from request.body
    try {
      // Get access token
      const getToken = await axios({
        url: "https://api.iamport.kr/users/getToken",
        method: "post", // POST method
        headers: { "Content-Type": "application/json" }, // "Content-Type": "application/json"
        data: {
          imp_key: "imp_apikey", // REST API Key
          imp_secret: "ekKoeW8RyKuT0zgaZsUtXXTLQ4AhPFW3ZGseDA6bkA5lamv9OqDMnxyeB9wqOsuO9W3Mx9YSJ4dTqJ3f" // REST API Secret
        }
      });
      const { access_token } = getToken.data.response; // Access token
      ...
      // Get verification info from i'mport server using imp_uid
      const getCertifications = await axios({
        url: \`https://api.iamport.kr/certifications/\${imp_uid}\`, // Pass imp_uid
        method: "get", // GET method
        headers: { "Authorization": access_token } // Add access token to Authorization header
      });
      const certificationsInfo = getCertifications.data.response; // Save verification info
      ...
    } catch(e) {
      console.error(e);
    }
  });
```

{% endcode %}

### <mark style="color:blue;">**STEP 03.**</mark> Using verification information

Retrieve the following user information from the verification information and add the necessary service logic.

* `name`: name
* `gender`: gender
* `birth`: date of birth
* `unique_key`: same as CI value - unique key to identify the user, such as online social security number.
* `unique_in_site`: same as DI value - unique key to identify the user per Merchant ID (website).

{% hint style="info" %}
In addition to the above information, if you need access to a user's mobile phone number (**`phone`**) and carrier (**`carrier`**) or foreigner status (**`foreigner`**), you must post a **Consent to Provision of Personal Information on your website** and send a **request to&#x20;**<mark style="color:red;">**<cs@iamport.kr>**</mark>. Note that this service is available once it is requested to Danal PG and approved after contracting with i'mport.<br>

**\<Email request format >**

* Business name:
* Business registration number:
* Danal Merchant ID (CPID) for identity verification:
* Privacy Policy URL: If unable to provide the URL when using an app service, capture and send the 'Privacy Policy' path.

**\<Sample Privacy Policies of i'mport merchants>**

* `Marpple Co., Ltd.: https://marpple.shop/kr/@/privacy`
* `Brave Mobile Co., Ltd./Soomgo: https://soomgo.com/terms/privacy`
* `Marketit Co., Ltd.: https://static.marketit.asia/static/privacy-terms.pdf`
  {% endhint %}

{% code title="Node.js" %}

```javascript
  // controller that handles POST request to "/certifications"
  app.post("/certifications", async (request, response) => {
    const { imp_uid } = request.body; // Get imp_uid from request.body
    try {
      // Get access token
      /* ...Omitted... */
      // Get verification info using imp_uid 
      /* ...Omitted... */
      const certificationsInfo = getCertifications.data.response; // Save verification info
      // unique_key: Unique key for user, unique_in_site: Unique key for user per site
      const { unique_key, unique_in_site, name, gender, birth } = certificationsInfo;
      ...
      // Check age restrictions
      if (new Date(birth).getFullYear() <= 1999) {
        // Check successful
      } else {
        // Check failed
      }
      ...
      // one account per person check
      // Query database with unique_key to check for existing account
      Users.find({ certificationKey: unique_key })
      .then((user) => {
        if (!user) {
          // New user
        } else {
          // Existing user
        }
      });
    } catch(e) {
      console.error(e);
    }
  });
```

{% endcode %}
