Skip to content

Zero dependency library for generating a Mastercard API compliant OAuth signature.

License

Notifications You must be signed in to change notification settings

amin-nas/oauth1-signer-nodejs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Table of contents

Overview

Zero dependency library for generating a Mastercard API compliant OAuth signature.

Compatibility

Node 6.12.3+

References

OAuth 1.0a specification

Body hash extension for non application/x-www-form-urlencoded payloads

Usage

Prerequisites

Before using this library, you will need to set up a project and key in the Mastercard Developers Portal.

The two key pieces of information you will need are:

  • Consumer key
  • Private key matching the public key uploaded to Mastercard Developer Portal

Creating a valid OAuth string

The method that does all the heavy lifting is OAuth.getAuthorizationHeader. You can call into it directly and as long as you provide the correct parameters, it will return a string that you can add into your request's Authorization header.

	const consumerKey = "<insert consumer key from developer portal>";
	const signingKey = "<initialize private key matching the consumer key>";
	const uri = "https://sandbox.api.mastercard.com/service";
	const method = "GET";
	const payload = "Hello world!";

	const authHeader = OAuth.getAuthorizationHeader(uri, method, payload, consumerKey, signingKey);

About

Zero dependency library for generating a Mastercard API compliant OAuth signature.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%