# 액세스 토큰 발급받기

{% hint style="info" %}
API Key와 Secret Key를 통해 인증이 완료되면 액세스 토큰을 발급받을 수 있습니다. 발급받은 액세스 토큰은 모든 Rest API 요청 시 요청 헤더에 포함하여 전달해주셔야 합니다. 제휴사의 경우 업체 코드를 헤더로 전달해주셔야 합니다.
{% endhint %}

### 토큰 발급

<mark style="color:blue;">`GET`</mark> `https://api.imweb.me/v2/auth`

#### Query Parameters

| Name   | Type   | Description |
| ------ | ------ | ----------- |
| key    | string | API Key     |
| secret | string | Secret Key  |

#### Headers

| Name             | Type   | Description                                                                        |
| ---------------- | ------ | ---------------------------------------------------------------------------------- |
| ACCESS-AFFILIATE | string | <p><strong>제휴사 업체 코드</strong><br><br>제휴사의 경우에만 입력합니다.<br>제휴사 코드는 담당자에게 문의바랍니다.</p> |

{% tabs %}
{% tab title="200 " %}

```
{"msg":"SUCCESS","code":200,"access_token":"{ACCESS_TOKEN}"}
```

{% endtab %}
{% endtabs %}

### 호출 예시

{% tabs %}
{% tab title="CURL" %}

```bash
curl -d '{"key": "{API_KEY}", "secret":"{SECRET}"}' https://api.imweb.me/v2/auth
```

{% endtab %}

{% tab title="PHP" %}

```bash
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.imweb.me/v2/auth');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1) ;
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
	'key'=> '{API_KEY}',
	'secret'=> '{SECRET}',
]));
$res = curl_exec($ch);
curl_close($ch);
```

{% endtab %}
{% endtabs %}

### 응답 데이터

```
{"msg":"SUCCESS","code":200,"access_token":"{ACCESS_TOKEN}"}
```

| 항목            | 타입      | 설명         |
| ------------- | ------- | ---------- |
| msg           | string  | 응답 메세지     |
| code          | integer | 응답 코드      |
| http\_code    | integer | http 상태 코드 |
| access\_token | string  | 액세스 토큰     |


---

# Agent Instructions: 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://old-developers.imweb.me/getstarted/token.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.
