Download the PHP package mastercard/oauth1-signer without Composer
On this page you can find all versions of the php package mastercard/oauth1-signer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mastercard/oauth1-signer
More information about mastercard/oauth1-signer
Files in mastercard/oauth1-signer
Package oauth1-signer
Short Description Zero dependency library for generating a Mastercard API compliant OAuth signature.
License MIT
Informations about the package oauth1-signer
oauth1-signer-php
Table of Contents
- Overview
- Compatibility
- References
- Versioning and Deprecation Policy
- Usage
- Prerequisites
- Adding the Library to Your Project
- Loading the Signing Key
- Creating the OAuth Authorization Header
- Signing HTTP Client Request Objects
- Integrating with OpenAPI Generator API Client Libraries
Overview
Zero dependency library for generating a Mastercard API compliant OAuth signature.
Compatibility
PHP 5.6+
References
Versioning and Deprecation Policy
Usage
Prerequisites
Before using this library, you will need to set up a project in the Mastercard Developers Portal.
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)
Adding the Library to Your Project
Loading the Signing Key
A private key object can be created by calling the AuthenticationUtils::loadSigningKey
function:
Creating the OAuth Authorization Header
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.
Signing HTTP Client Request Objects
Alternatively, you can use helper classes for some of the commonly used HTTP clients.
These classes, provided in the Mastercard\Developer\Signers\
namespace, will modify the provided request object in-place and will add the correct Authorization
header. Once instantiated with a consumer key and private key, these objects can be reused.
Usage briefly described below, but you can also refer to the test namespace for examples.
- cURL
- GuzzleHttp
cURL
POST example
GET example
GuzzleHttp
Integrating with OpenAPI Generator API Client Libraries
OpenAPI Generator generates API client libraries from OpenAPI Specs. It provides generators and library templates for supporting multiple languages and frameworks.
This project provides you with classes you can use when configuring your API client. These classes will take care of adding the correct Authorization
header before sending the request.
Generators currently supported:
- php
php
OpenAPI Generator
Client libraries can be generated using the following command:
See also: