# insomnia-plugin-mastercard-auth

> An Insomnia plugin for handling authentication when integrating with Mastercard APIs

Latest version **1.1.14** (published 2022-04-08) · Apache-2.0 license · 0 weekly downloads

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

## Install

```sh
npm install insomnia-plugin-mastercard-auth
pnpm add insomnia-plugin-mastercard-auth
yarn add insomnia-plugin-mastercard-auth
bun add insomnia-plugin-mastercard-auth
```

## Health

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

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.1.14 |
| Published | 2022-04-08 |
| First published | 2018-03-28 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 28.7 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | mastercardapi |

## Links

- npm: https://www.npmjs.com/package/insomnia-plugin-mastercard-auth
- Repository: https://github.com/Mastercard/insomnia-plugin-mastercard-auth
- Homepage: https://github.com/Mastercard/insomnia-plugin-mastercard-auth#readme
- Issues: https://github.com/Mastercard/insomnia-plugin-mastercard-auth
- npm.io page: https://npm.io/package/insomnia-plugin-mastercard-auth

## Dependencies (3)

- [node-forge](https://npm.io/package/node-forge.md) >=0.10.0
- [insomnia-url](https://npm.io/package/insomnia-url.md) ^0.1.2
- [mastercard-oauth1-signer](https://npm.io/package/mastercard-oauth1-signer.md) 1.1.5

## Recent versions

- 1.1.14 (latest) — 2022-04-08
- 1.1.13 — 2021-11-08
- 1.1.12 — 2021-05-06
- 1.1.11 — 2021-05-05
- 1.1.10 — 2021-03-22
- 1.1.8 — 2021-03-08
- 1.1.7 — 2020-11-02
- 1.1.6 — 2020-10-30
- 1.1.5 — 2020-09-02
- 1.1.4 — 2020-06-04
- 1.1.3 — 2020-02-06
- 1.1.2 — 2020-02-04
- 1.1.1 — 2019-10-21
- 1.1.0 — 2019-10-08
- 1.0.5 — 2019-01-08
- … 4 more at https://npm.io/package/insomnia-plugin-mastercard-auth/versions

## README

# insomnia-plugin-mastercard 
[![](https://developer.mastercard.com/_/_/src/global/assets/svg/mcdev-logo-dark.svg)](https://developer.mastercard.com/)

[![](https://sonarcloud.io/api/project_badges/measure?project=Mastercard_insomnia-plugin-mastercard&metric=alert_status)](https://sonarcloud.io/dashboard?id=Mastercard_insomnia-plugin-mastercard)
[![](https://github.com/Mastercard/insomnia-plugin-mastercard-auth/workflows/broken%20links%3F/badge.svg)](https://github.com/Mastercard/insomnia-plugin-mastercard-auth/actions?query=workflow%3A%22broken+links%3F%22)
[![](https://img.shields.io/npm/v/insomnia-plugin-mastercard-auth.svg)](https://www.npmjs.com/package/insomnia-plugin-mastercard-auth)
[![](https://img.shields.io/badge/license-Apache%202.0-yellow.svg)](https://github.com/Mastercard/insomnia-plugin-mastercard-auth/blob/master/LICENSE)
[![](https://img.shields.io/badge/insomnia-install%20workspace-purple.svg?color=6a57d5)](https://insomnia.rest/run/?label=Import%20Mastercard%20Workspace&uri=https://raw.githubusercontent.com/Mastercard/insomnia-plugin-mastercard-auth/master/workspace/mastercard-apis-insomnia-workspace.json)

## Table of Contents
- [Overview](#overview)
  * [Compatibility](#compatibility)
  * [References](#references)
- [Usage](#usage)
  * [Prerequisites](#prerequisites)
  * [Installation](#installation)
  * [Configuration](#configuration)
  * [Authenticated Requests](#authenticated-requests)
- [Further Reading](#further-reading)

## Overview <a name="overview"></a>
A plugin for handling Mastercard API authentication. This plugin computes and adds an `Authorization` header to requests sent from [Insomnia REST Client](https://insomnia.rest/).

### Compatibility <a name="compatibility"></a>
Insomnia v5.15.0+

### References <a name="references"></a>
* [Using OAuth 1.0a to Access Mastercard APIs](https://developer.mastercard.com/platform/documentation/security-and-authentication/using-oauth-1a-to-access-mastercard-apis/)
* [A Mastercard Plugin for Insomnia REST Client](https://developer.mastercard.com/blog/a-mastercard-plugin-for-insomnia-rest-client)

## Usage <a name="usage"></a>

### Prerequisites <a name="prerequisites"></a>
Before using this library, you will need to set up a project in the [Mastercard Developers Portal](https://developer.mastercard.com). 

As part of this set up, you'll receive credentials for your app:
* A consumer key (displayed on the Mastercard Developer Portal)
* A private request signing key (matching the public certificate displayed on the Mastercard Developer Portal)

### Installation <a name="installation"></a>

#### 1. One-Click Installation
1. Go to https://insomnia.rest/plugins/insomnia-plugin-mastercard-auth
2. Click the "Install Plugin" button
3. Click "Open Insomnia" and "Install"

#### 2. From the Plugins Tab
1. Open Insomnia
2. Go to Application > Preferences > Plugins
3. Type "insomnia-plugin-mastercard-auth"
4. Click "Install Plugin"

![](https://user-images.githubusercontent.com/3964455/67882592-66a0cd00-fb3a-11e9-9e57-15736b605396.gif)

#### 3. Manual Installation
1. Download "insomnia-plugin-mastercard-auth-{version}.zip" from [Releases > Assets](https://github.com/Mastercard/insomnia-plugin-mastercard-auth/releases)
2. Go to Application > Preferences > Plugins
3. Click "Reveal Plugins Folder"
4. Extract the ZIP file from step 1 to the "plugins" folder
5. Click "Reload Plugins"

![](https://user-images.githubusercontent.com/3964455/67882595-66a0cd00-fb3a-11e9-8909-f2188f9a94da.gif)

### Configuration <a name="configuration"></a>

#### One-Click Import
To import two ready to be used "sandbox" and "production" environments:
1. Click [![](https://img.shields.io/badge/insomnia-install%20workspace-purple.svg?color=6a57d5)](https://insomnia.rest/run/?label=Import%20Mastercard%20Workspace&uri=https://raw.githubusercontent.com/Mastercard/insomnia-plugin-mastercard-auth/master/workspace/mastercard-apis-insomnia-workspace.json)
2. Click "Run Import Mastercard Workspace"

Alternatively, you can:
1. Go to Application > Preferences > Data
2. Click "Import Data"
3. Click "From URL"
4. Type: https://raw.githubusercontent.com/Mastercard/insomnia-plugin-mastercard-auth/master/workspace/mastercard-apis-insomnia-workspace.json
5. Click "Fetch and Import"

![](https://user-images.githubusercontent.com/3964455/68041294-2d966300-fcc8-11e9-887a-cfadf183c4c1.gif)

#### Manual Configuration
Update your [environment](https://support.insomnia.rest/article/18-environment-variables):
1. Click "Manage Environments"
2. Create a "mastercard" environment variable with your credentials:

Linux/macOS
```json
{
  "mastercard": {
    "consumerKey": "000000000000000000000000000000000000000000000000!000000000000000000000000000000000000000000000000",
    "keyAlias": "keyalias",
    "keystoreP12Path": "/path/to/sandbox-signing-key.p12",
    "keystorePassword": "keystorepassword",
    "appliesTo": [
      "mastercard.com",
      "api.ethocaweb.com"
    ]
  }
}
```
Windows
```json
{
  "mastercard": {
    "consumerKey": "000000000000000000000000000000000000000000000000!000000000000000000000000000000000000000000000000",
    "keyAlias": "keyalias",
    "keystoreP12Path": "C:\\path\\to\\sandbox-signing-key.p12",
    "keystorePassword": "keystorepassword",
    "appliesTo": [
      "mastercard.com",
      "api.ethocaweb.com"
    ]
  }
}
```

### Authenticated Requests <a name="authenticated-requests"></a>
From now on, an `Authorization` header will be automatically added to every request sent to Mastercard:

![](https://user-images.githubusercontent.com/3964455/68042376-a72f5080-fcca-11e9-85d9-d60cdd2da920.gif)

## Further Reading <a name="further-reading"></a>
* [Insomnia Plugins](https://support.insomnia.rest/article/26-plugins)
* [The Insomnia Plugin Hub](https://insomnia.rest/plugins)
* [oauth1-signer-nodejs](https://github.com/Mastercard/oauth1-signer-nodejs) — A zero dependency library for generating a Mastercard API compliant OAuth signature

---
_Source: https://npm.io/package/insomnia-plugin-mastercard-auth · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
