# Markefanへログインする

Markefanにログインを行うAPIです。\
Markefanの各APIを使用するときには、最初にこのログインAPIを用いてユーザーIDやアクセストークンを取得する必要があります。

## HTTP種類 : POST

## URL : \[BASE URL]/SpringRest/account/user/login

## パラメータ

|    名 前   |    型   |  必 須 |
| :------: | :----: | :--: |
| Username | String | True |
| Password | String | True |

※Passwordは、MD5でハッシュ化した値を渡します。

## HTTP戻り値 : JSON

## JSON戻り値 例：

```javascript
{
    "code": 200,
    "message": "LOGIN SUCCESS",
    "status": "OK",
    "generatedId": null,
    "generatedIds": null,
    "statusObject": "OK",
    "account": {
        "accountId": null,
        "name": "",
        "companyName": "",
        "companyUrl": null,
        "creationDate": null
    },
    "user": {
        "userId": null,
        "name": "",
        "firstName": "",
        "lastName": "",
        "role": null
    },
    "auth": {
        "accessToken": "",
        "tokenType": "bearer",
        "refreshToken": "",
        "expiresIn": 3000,
        "scope": "[read, trust, write]"
    }
}
```

## サンプルコード

This method used for login, you have to pass username and password as the parameter to this method and it will return the response from API. It contains users details, such as userId, accessToken etc.

```java
private String loginApi(String username, String password) {
    try {
        HttpClient client = new DefaultHttpClient();
        HttpPost httpPost = new HttpPost("<API_BASE_URL>/SpringRest/account/user/login");
        List<NameValuePair> Parameter = new ArrayList<NameValuePair>();
        Parameter.add(new BasicNameValuePair("username", username));
        Parameter.add(new BasicNameValuePair("password", password));
        HttpEntity entity = new UrlEncodedFormEntity(Parameter);
        httpPost.setEntity(entity);
        HTTPResponse response = client.execute(httpPost);
        BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
        String line = "";
        while ((line = rd.readLine()) != null) {

        return  line;
        }
    } catch (UnsupportedEncodingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return null;
}
```

## 呼び出し方法

```java
String responseJson = loginApi("admin","admin");
```


---

# 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://markefan.gitbook.io/documents/index/userlogin.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.
