# @adobe/aio-lib-core-ims-oauth

> OAuth2 (SUSI) token creation plugin for @adobe/aio-lib-core-ims

Latest version **1.2.0** (published 2020-02-14) · Apache-2.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @adobe/aio-lib-core-ims-oauth
pnpm add @adobe/aio-lib-core-ims-oauth
yarn add @adobe/aio-lib-core-ims-oauth
bun add @adobe/aio-lib-core-ims-oauth
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2020-02-14 |
| First published | 2019-12-10 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=10.0.0 |
| Dependencies | 3 |
| Unpacked size | 34.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Adobe Inc. |
| Maintainers | aaronius, adobe-admin, adobe-behance, aemsites, alexkli, andreea_dracea, ashryan, aspro83, bbythewa, benjamind, bglowacki, bpauli, dcpfsdk, devongovett, dompuiu, dpfister, filmaj, fmeschbe, garthdb, goya, himar, hirenoble, ibaratz, icaraps, jckautzmann, jfkhoury, jianliao79, justinedelson, kerrishotts, korra, kptdobe, krisnye, lazd, macdonst, marbec, meryllblanchet, mfrisbey, moritzraho, msagolj, natebaldwin, nporter-adbe, purplecabbage, richardhand, rofe, ronen, shazron, stefan-guggisberg, target-admin, trieloff, tripod, vladbailescu, yoshikinoko |

## Links

- npm: https://www.npmjs.com/package/@adobe/aio-lib-core-ims-oauth
- Repository: https://github.com/adobe/aio-lib-core-ims-oauth
- Issues: https://github.com/adobe/aio-lib-core-ims-oauth/issues
- npm.io page: https://npm.io/package/@adobe/aio-lib-core-ims-oauth

## Dependencies (3)

- [ora](https://npm.io/package/ora.md) ^4.0.3
- [debug](https://npm.io/package/debug.md) ^4.1.1
- [cli-ux](https://npm.io/package/cli-ux.md) ^5.3.3

## Recent versions

- 1.2.0 (latest) — 2020-02-14
- 1.1.0 — 2020-02-12
- 1.0.1 — 2020-02-10
- 1.0.0 — 2020-02-10
- 0.0.3 — 2019-12-17
- 0.0.2 — 2019-12-11
- 0.0.1 — 2019-12-10

## README

@adobe/aio-lib-core-ims-oauth
==========================

OAuth2 (SUSI) token creation plugin for [`aio-lib-core-ims`](https://github.com/adobe/aio-lib-core-ims).

[![Version](https://img.shields.io/npm/v/@adobe/aio-lib-core-ims-oauth.svg)](https://npmjs.org/package/@adobe/aio-lib-core-ims-oauth)
[![Downloads/week](https://img.shields.io/npm/dw/@adobe/aio-lib-core-ims-oauth.svg)](https://npmjs.org/package/@adobe/aio-lib-core-ims-oauth)
[![Build Status](https://travis-ci.com/adobe/aio-lib-core-ims-oauth.svg?branch=master)](https://travis-ci.com/adobe/aio-lib-core-ims-oauth)
[![Codecov Coverage](https://img.shields.io/codecov/c/github/adobe/aio-lib-core-ims-oauth/master.svg?style=flat-square)](https://codecov.io/gh/adobe/aio-lib-core-ims-oauth/)
[![License](https://img.shields.io/npm/l/@adobe/aio-lib-core-ims-oauth.svg)](https://github.com/adobe/aio-lib-core-ims-oauth/blob/master/package.json)
[![Greenkeeper badge](https://badges.greenkeeper.io/adobe/aio-lib-core-ims-oauth.svg)](https://greenkeeper.io/)

This plugin is intended to be used in conjunction with the [`aio-lib-core-ims`](https://github.com/adobe/aio-lib-core-ims) extending that to support browser based 3-legged OAuth2 authentication with IMS commonly known as _SUSI flow_.

For more information about the general setup of the Adobe I/O CLI IMS Plugin, please refer to [`aio-lib-core-ims`](https://github.com/adobe/aio-lib-core-ims).

The 3-legged OAuth2 requires interaction with a browser as the initial authentication step to receive the authorization code may be involving multiple browser based steps.
For example an IMS Enterprise integration may involve further redirects to a 3rd party for actual authentication.

Workflow:
1. A 4-byte random pass-code is generated
2. A localhost web server is created, listening at a port number
3. An Adobe I/O Runtime web action is opened in the browser, passing in this pass-code, the localhost web server port number, the client id, and the IMS scope as query parameters
3. The Adobe I/O Runtime web action will redirect to the IMS authorization endpoint, with the scope, client id and a [csrf](https://en.wikipedia.org/wiki/Cross-site_request_forgery) token as the `state` property (derived from the id, client id, scope and localhost port) passed in as query parameters
4. When the user is authenticated or an error occurs, the IMS endpoint will redirect to the Adobe I/O Runtime web action's `login-success` path
5. If the authentication is successful, the Adobe I/O Runtime web action will redirect to the localhost web server at the specified port (derived from the `state` property), and forward the `state` and `code` properties to the localhost web server call as query parameters
6. The localhost web server will pass on the authorization code to the library, and the library will call an IMS endpoint to exchange the authorization code for an access token and refresh token
7. If the authentication is not successful, the Adobe I/O Runtime web action will report an error message in the web browser

The Adobe I/O Runtime function used (currently in testing) is coming soon.

# Config 

Add the `oauth2` context into your `.aio` file in your current working directory (project folder), under `$ims`:
```javascript
{
  $ims: {
    oauth2: {
        redirect_uri: "YOUR_REDIRECT_URI",
        client_id: "YOUR_CLIENT_ID",
        client_secret: "YOUR_CLIENT_SECRET",
        scope: "YOUR_IMS_SCOPE"
    }
  }
}
```
The context can be named anything (here `oauth2` is chosen for the context name).


# Contributing
Contributions are welcomed! Read the [Contributing Guide](CONTRIBUTING.md) for more information.


# Licensing

This project is licensed under the Apache V2 License. See [LICENSE](LICENSE) for more information.

---
_Source: https://npm.io/package/@adobe/aio-lib-core-ims-oauth · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
