GithubHelp home page GithubHelp logo

oauth-negotiator's Introduction

OAuth Negotiator.

Total Downloads Latest Stable Version License

OAuth negotiator is a PHP Guzzle HTTP v6.x Client Middleware that will help you acquire, and refresh your access tokens automatically per application request to the OAuth2 server so you don't have to worry about non-existent or expired access tokens.

This package works by tapping into each request.

  • First, checking if the request has an authorization header; if present, proceed to execute the request.
  • If the request has no set authorization header, the available access token in storage is then added as the request authorization header.
  • If no access token is present in storage, it shall request for a new access token from the OAuth server using the main grant type specified.
  • If there's an existing access token in storage, but it's expired, and a refresh token grant was specified, it shall try to refresh the expired access token using the available refresh token.

See flowchart for detailed process illustration.

Grant types

The package supports four grant types out of box, that is; Client Credentials, Refresh Token, Password, and the Authorization Code grant type*.

You can implement your own custom grant type by simply implementing the GrantTypeInterface.

Tokens

These are the object mapping to the real life access token you would get from an OAuth Server. They implement the TokenInterface.

Token storage

The package also defaults to a file based persistent token storage, but you can still implement your custom persistent storage, say a session based token storage by implementing the TokenRepositoryInterface.

Exceptions

  • TokenNotFoundException thrown by the token repository whenever in case of an unknown token.
  • TokenRequestException thrown by grant type on failure to acquire an access token.

Source code documentation

Installation

The package can be installed via composer.

composer require bmatovu/oauth-negotiator

Usage

Auto-load the package using composer so that it's available in your application scope.

<?php
    
    require __DIR__ . '/../vendor/autoload.php';
    
    // do something...

Real documentation is still a work in progress, but for now examine the tests.

oauth-negotiator's People

Contributors

mtvbrianking avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

oauth-negotiator's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.