shabeer/foodics-ouath2-merchant
Composer 安装命令:
composer require shabeer/foodics-ouath2-merchant
包简介
Foodics OAuth 2.0 Client Provider for The PHP League OAuth2-Client
README 文档
README
Foodics OAuth 2.0 Client
Overview
To use this package, it will be necessary to have a Foodics client ID and client secret. These are referred to as {client-id} and {client-secret} in the documentation.
Installation
You can install the package via composer:
composer required shabeer/foodics-ouath2-merchant
Usage
Authorization Code Flow
<?php require_once './vendor/autoload.php'; use Foodics\OAuth2\Client\Provider\Foodics; $provider = new Foodics([ 'clientId' => '{client-id}', // The client ID assigned to you by Salla 'clientSecret' => '{client-secret}', // The client password assigned to you by Salla 'redirectUri' => 'https://yourservice.com/callback_url', // the url for current page in your service ]); if (!isset($_GET['code']) || empty($_GET['code'])) { // If we don't have an authorization code then get one $authUrl = $provider ->setBaseUrl('https://console.foodics.com') ->getAuthorizationUrl([ 'scope' => 'general.read', ]); header('Location: '.$authUrl); exit; } // Try to obtain an access token by utilizing the authorisations code grant. try { $token = $provider->getAccessToken('authorization_code', [ 'code' => $_GET['code'] ]); // // ## Access Token // // You should store the access token // which may use in authenticated requests against the Salla's API echo 'Access Token: '.$token->getToken()."<br>"; // // ## Refresh Token // // You should store the refresh token somewhere in your system because the access token expired after 14 days // so you can use the refresh token after that to generate a new access token without asking any access from the merchant // // $token = $provider->getAccessToken(new RefreshToken(), ['refresh_token' => $token->getRefreshToken()]); // echo 'Refresh Token: '.$token->getRefreshToken()."<br>"; // // ## Expire date // // This helps you to know when the access token will be expired // so before that date, you should generate a new access token using the refresh token echo 'Expire Date : '.$token->getExpires()."<br>"; /** @var \Foodics\OAuth2\Client\Provider\FoodicsUser $user */ $user = $provider->getResourceOwner($token); var_export($user->toArray()); } catch (\League\OAuth2\Client\Provider\Exception\IdentityProviderException $e) { // Failed to get the access token or merchant details. // show a error message to the merchant with good UI exit($e->getMessage()); }
Refreshing a Token
Refresh tokens are only provided to applications that request offline access. You can specify offline access by passing the scope option in your getAuthorizationUrl() request.
use Foodics\OAuth2\Client\Provider\Foodics; $provider = new Foodics([ 'clientId' => '{client-id}', 'clientSecret' => '{client-secret}', ]); $refreshToken = 'FromYourStoredData'; $token = $provider->getAccessToken('refresh_token', ['refresh_token' => $refreshToken]); ## Contributing Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**. If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again! 1. Fork the Project 2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`) 3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`) 4. Push to the Branch (`git push origin feature/AmazingFeature`) 5. Open a Pull Request <p align="right">(<a href="#top">back to top</a>)</p>
shabeer/foodics-ouath2-merchant 适用场景与选型建议
shabeer/foodics-ouath2-merchant 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.26k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 06 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「authorization」 「client」 「oauth」 「oauth2」 「authorisation」 「foodics」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 shabeer/foodics-ouath2-merchant 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 shabeer/foodics-ouath2-merchant 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 shabeer/foodics-ouath2-merchant 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
WeChat OAuth SDK
Ory-Hydra OAuth 2.0 Client Provider for The PHP League OAuth2-Client
Library for ORCID web services
A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.
Mock PSR-18 HTTP client
Asynchronous MQTT client built on React
统计信息
- 总下载量: 3.26k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-06-16