|
1 | 1 | # insomnia-plugin-mastercard-auth |
2 | 2 |
|
3 | | -Mastercard API authentication plugin for Insomnia REST Client. |
| 3 | +[](https://www.npmjs.com/package/insomnia-plugin-mastercard-auth) |
| 4 | +[](https://github.com/Mastercard/insomnia-plugin-mastercard-auth/blob/master/LICENSE) |
4 | 5 |
|
5 | | -## Installation |
| 6 | +## Table of Contents |
| 7 | +- [Overview](#overview) |
| 8 | + * [Compatibility](#compatibility) |
| 9 | + * [References](#references) |
| 10 | +- [Usage](#usage) |
| 11 | + * [Prerequisites](#prerequisites) |
| 12 | + * [Installation](#installation) |
| 13 | + * [Configuration](#configuration) |
| 14 | + * [Authenticated Requests](#authenticated-requests) |
| 15 | +- [Further Reading](#further-reading) |
6 | 16 |
|
7 | | -Install the `insomnia-plugin-mastercard-auth` plugin from Preferences > Plugins. |
| 17 | +## Overview <a name="overview"></a> |
| 18 | +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/). |
8 | 19 |
|
9 | | -## Usage |
| 20 | +### Compatibility <a name="compatibility"></a> |
| 21 | +Insomnia v5.15.0+ |
10 | 22 |
|
11 | | -Add Mastercard API keys by setting a `mastercard` environment variable. |
| 23 | +### References <a name="references"></a> |
| 24 | +* [Using OAuth 1.0a to Access Mastercard APIs](https://developer.mastercard.com/platform/documentation/using-oauth-1a-to-access-mastercard-apis/) |
| 25 | +* [A Mastercard Plugin for Insomnia REST Client](https://developer.mastercard.com/blog/a-mastercard-plugin-for-insomnia-rest-client) |
| 26 | + |
| 27 | +## Usage <a name="usage"></a> |
| 28 | + |
| 29 | +### Prerequisites <a name="prerequisites"></a> |
| 30 | +Before using this library, you will need to set up a project in the [Mastercard Developers Portal](https://developer.mastercard.com). |
| 31 | + |
| 32 | +As part of this set up, you'll receive credentials for your app: |
| 33 | +* A consumer key (displayed on the Mastercard Developer Portal) |
| 34 | +* A private request signing key (matching the public certificate displayed on the Mastercard Developer Portal) |
| 35 | + |
| 36 | +### Installation <a name="installation"></a> |
| 37 | + |
| 38 | +1. Open Insomnia |
| 39 | +2. Go to Application > Preferences > Plugins |
| 40 | +3. Type "insomnia-plugin-mastercard-auth" |
| 41 | +4. Click "Install Plugin" |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | +### Configuration <a name="configuration"></a> |
| 46 | + |
| 47 | +Update your [environment](https://support.insomnia.rest/article/18-environment-variables): |
| 48 | +1. Click "Manage Environments" |
| 49 | +2. Create a "mastercard" environment variable with your credentials: |
12 | 50 |
|
13 | 51 | ```json |
14 | 52 | { |
15 | | - "mastercard": { |
16 | | - "consumerKey": "[YOUR CONSUMER KEY]", |
17 | | - "keyAlias": "[YOUR KEY ALIAS]", |
18 | | - "keystoreP12Path": "[YOUR KEYSTORE .P12 PATH]", |
19 | | - "keystorePassword": "[YOUR KEYSTORE PASSWORD]" |
20 | | - } |
| 53 | + "mastercard": { |
| 54 | + "consumerKey": "000000000000000000000000000000000000000000000000!000000000000000000000000000000000000000000000000", |
| 55 | + "keyAlias": "keyalias", |
| 56 | + "keystoreP12Path": "/path/to/sandbox-signing-key.p12", |
| 57 | + "keystorePassword": "keystorepassword" |
| 58 | + } |
21 | 59 | } |
22 | 60 | ``` |
| 61 | + |
| 62 | + |
| 63 | +### Authenticated Requests <a name="authenticated-requests"></a> |
| 64 | +From now on, an `Authorization` header will be automatically added to every request sent to Mastercard: |
| 65 | + |
| 66 | + |
| 67 | + |
| 68 | +## Further Reading <a name="further-reading"></a> |
| 69 | +* [Insomnia Plugins](https://support.insomnia.rest/article/26-plugins) |
| 70 | +* [oauth1-signer-nodejs](https://github.com/Mastercard/oauth1-signer-nodejs) — A zero dependency library for generating a Mastercard API compliant OAuth signature |
0 commit comments