sarahman/oauth-tokens-client
Composer 安装命令:
composer require sarahman/oauth-tokens-client
包简介
This package handles the oauth tokens with caching functionality.
README 文档
README
PHP library built by PSR-16 simple cache interface can be used in any php project or it has laravel support to install through its service provider.
Installation
- Step 1: You can install the package via composer:
composer require sarahman/oauth-tokens-client
- Step 2.a: Next, for the laravel projects, we can load its service provider:
// app/config/app.php 'providers' => [ ... 'Sarahman\OauthTokensClient\OauthTokensClientServiceProvider', ];
You can publish the config file with:
php artisan config:publish sarahman/oauth-tokens-client
This is the contents of the published config file:
return array( 'TOKEN_PREFIXES' => array( 'ACCESS' => 'oauth_access_token', 'REFRESH' => 'oauth_refresh_token', ), 'LOCK_KEY' => 'oauth_token_refresh_lock', 'OAUTH_CREDENTIAL' => array( 'GRANT_TYPE' => 'client_credentials', 'TOKEN_URL' => null, 'REFRESH_URL' => null, 'CLIENT_ID' => null, 'CLIENT_SECRET' => null, 'USERNAME' => null, 'PASSWORD' => null, 'SCOPE' => '', ), );
Note: If we use password grant, then we must set USERNAME and PASSWORD config keys.
- Step 2.b: for the regular php projects, we might directly add these following codes:
require "vendor/autoload.php"; $clientConfig = array( 'TOKEN_PREFIXES' => array( 'ACCESS' => 'oauth_access_token', 'REFRESH' => 'oauth_refresh_token', ), 'LOCK_KEY' => 'oauth_token_refresh_lock', 'OAUTH_CREDENTIAL' => array( 'GRANT_TYPE' => 'client_credentials', 'TOKEN_URL' => 'http://localhost/grant-token', 'REFRESH_URL' => 'http://localhost/refresh-token', 'CLIENT_ID' => 1, 'CLIENT_SECRET' => '**********', 'SCOPE' => '', ), ); $client = new OAuthClient( new Client, <CACHE_STORE>, $clientConfig['OAUTH_CREDENTIAL'], $clientConfig['TOKEN_PREFIXES'], $clientConfig['LOCK_KEY'] ); // Set Cache key. $data = array( 'sample' => 'data', 'another' => 'data', ); $response = $client->request('POST', 'http://localhost/get-user', $data); var_dump($response);
Testing
You might go to the project directory and run the following command to run test code.
composer test
Contribution
Feel free to contribute in this library. Please make your changes and send us pull requests.
Security Issues
If you discover any security related issues, please feel free to create an issue in the issue tracker or write us at aabid048@gmail.com.
License
The MIT License (MIT). Please see License File for more information.
sarahman/oauth-tokens-client 适用场景与选型建议
sarahman/oauth-tokens-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.63k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 06 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「cache」 「client」 「library」 「oauth」 「laravel」 「passport」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 sarahman/oauth-tokens-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sarahman/oauth-tokens-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 sarahman/oauth-tokens-client 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
repository php library
Laravel 5 - Repositories to the database layer
Inbox pattern process implementation for your Laravel Applications
Mock PSR-18 HTTP client
Asynchronous MQTT client built on React
Core library that defines common interfaces used by the rest of the intahwebz..
统计信息
- 总下载量: 3.63k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 27
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-06-11