# rest-client-cognito

> Cognito Simple Authentication Server

Latest version **1.0.0** (published 2019-12-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install rest-client-cognito
pnpm add rest-client-cognito
yarn add rest-client-cognito
bun add rest-client-cognito
```

Provides the command `rcc`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2019-12-03 |
| First published | 2019-12-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 166.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Akasaki |
| Maintainers | akasaki |
| Keywords | Cognito, REST Client |

## Links

- npm: https://www.npmjs.com/package/rest-client-cognito
- Repository: https://github.com/AkasakiTomohiro/RestClientCognito
- Homepage: https://github.com/AkasakiTomohiro/RestClientCognito#readme
- Issues: https://github.com/AkasakiTomohiro/RestClientCognito/issues
- npm.io page: https://npm.io/package/rest-client-cognito

## Dependencies (3)

- [dotenv](https://npm.io/package/dotenv.md) ^8.2.0
- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.0
- [amazon-cognito-identity-js](https://npm.io/package/amazon-cognito-identity-js.md) ^3.2.0

## Recent versions

- 1.0.0 (latest) — 2019-12-03

## README

# Rest Client Cognito

このツールはCognitoからアクセストークンを取得するための認証用Webサーバーを起動するものになっています。

## 開発背景

私はVisual Studio Code Extensionの[REST Client](https://marketplace.visualstudio.com/items?itemName=humao.rest-client)を用いてWebAPIの検証を行っていました。  
しかし、このExtensionだけではCognitoのアクセストークンを取得することができません。  
なので、Cognitoの認証サーバーをnodeを用いて簡易にアクセストークンを取得できれば検証作業が簡易になると思いこのツールを作成しました。

## 準備

準備としてプロジェクトフォルダ直下に`.env`ファイルを作成してください。
その中には次の項目を必ず含めるようにしてください。

- `RCC_USER_POOL_ID`: CognitoのユーザープールID
- `RCC_CLIENT_ID`: アプリクライアントID
- `RCC_USER_NAME`: ログインするユーザー名
- `RCC_PASSWORD`: ログインするユーザーのパスワード

## 使用方法

`rcc`か`rcc -p 4000`コマンドをコールするだけでCognito用認証サーバーが起動します。

`-p`オプションを使用することで起動するサーバーのポート番号を変更することができます。  
また、ポート番号のデフォルトは3000番になっています。

`curl localhost:3000/login`でアクセストークンを取得することができます。  
以下の構造が取得に成功した際のデータ構造になっています。

``` token.json
{
  "token": "アクセストーン"
}
```

REST Clientを記述しているファイルに次をコピーして利用してください。

``` RestClient.rest
@rccPort = 3000

###

# @name login

GET http://localhost:{{rccPort}}/login

@authToken = {{login.response.body.token}}
```

---
_Source: https://npm.io/package/rest-client-cognito · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
