定制 softonic/guzzle-oauth2-middleware 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

softonic/guzzle-oauth2-middleware

最新稳定版本:2.1.2

Composer 安装命令:

composer require softonic/guzzle-oauth2-middleware

包简介

Guzzle middleware with OAuth2 integration

README 文档

README

Latest Version Software License Build Status Coverage Status Quality Score Total Downloads Average time to resolve an issue Percentage of issues still open

This package provides middleware for guzzle for handling OAuth2 token negotiation and renewal on expiry transparently. It accecpts PHP League's OAuth 2.0 Clients.

Installation

To install, use composer:

composer require softonic/guzzle-oauth2-middleware

Usage

<?php
$options = [
    'clientId' => 'myclient',
    'clientSecret' => 'mysecret'
];

// Any provider extending League\OAuth2\Client\Provider\AbstractProvider will do
$provider = new Softonic\OAuth2\Client\Provider\Softonic($options);

// Send OAuth2 parameters and use token_options for any other parameters your OAuth2 provider needs
$config = ['grant_type' => 'client_credentials', 'scope' => 'myscope', 'token_options' => ['audience' => 'test_audience']];

// Any implementation of PSR-6 Cache will do
$cache = new \Symfony\Component\Cache\Adapter\FilesystemAdapter();

$client = \Softonic\OAuth2\Guzzle\Middleware\ClientBuilder::build(
    $provider,
    $config,
    $cache,
    ['base_uri' => 'https://foo.bar/']
);
$response = $client->request('POST', 'qux);

Testing

softonic/guzzle-oauth2-middleware has a PHPUnit test suite and a coding style compliance test suite using PHP CS Fixer.

To run the tests, run the following command from the project folder.

$ docker-compose run test

To run interactively using PsySH:

$ docker-compose run psysh

License

The Apache 2.0 license. Please see LICENSE for more information.

统计信息

  • 总下载量: 3.44M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 11
  • 点击次数: 2
  • 依赖项目数: 4
  • 推荐数: 0

GitHub 信息

  • Stars: 10
  • Watchers: 6
  • Forks: 8
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2026-01-04