pizdata/oauth2-shopify
Composer 安装命令:
composer require pizdata/oauth2-shopify
包简介
Shopify OAuth 2.0 Client Provider for The PHP League OAuth2-Client
README 文档
README
Shopify OAuth 2.0 Client Provider.
Install
Via Composer
$ composer require pizdata/oauth2-shopify
Usage
$provider = new Pizdata\OAuth2\Client\Provider\Shopify([ 'clientId' => '{shopify-client-id}', // The client ID assigned to you by the Shopify 'clientSecret' => '{shopify-client-secret}', // The client password assigned to you by the Shopify 'redirectUri' => 'http://localhost/callback', // The redirect URI assigned to you 'shop' => 'pizdata.myshopify.com', // The Shop name ]); // If we don't have an authorization code then get one if (!isset($_GET['code'])) { // Setting up scope $options = [ 'scope' => [ 'read_content', 'write_content', 'read_themes', 'write_themes', 'read_products', 'write_products', 'read_customers', 'write_customers', 'read_orders', 'write_orders', 'read_draft_orders', 'write_draft_orders', 'read_script_tags', 'write_script_tags', 'read_fulfillments', 'write_fulfillments', 'read_shipping', 'write_shipping', 'read_analytics', ] ]; // Fetch the authorization URL from the provider; this returns the // urlAuthorize option and generates and applies any necessary parameters // (e.g. state). $authorizationUrl = $provider->getAuthorizationUrl($options); // Get the state generated for you and store it to the session. $_SESSION['oauth2state'] = $provider->getState(); // Redirect the user to the authorization URL. header('Location: ' . $authorizationUrl); exit; // Check given state against previously stored one to mitigate CSRF attack } elseif (empty($_GET['state']) || (isset($_SESSION['oauth2state']) && $_GET['state'] !== $_SESSION['oauth2state'])) { if (isset($_SESSION['oauth2state'])) { unset($_SESSION['oauth2state']); } exit('Invalid state'); } else { try { // Try to get an access token using the authorization code grant. $accessToken = $provider->getAccessToken('authorization_code', [ 'code' => $_GET['code'] ]); $store = $provider->getResourceOwner($accessToken); // Access to Store base information echo $store->getName(); echo $store->getEmail(); echo $store->getDomain(); // Use this to interact with an API on the users behalf echo $token->getToken(); } catch (\League\OAuth2\Client\Provider\Exception\IdentityProviderException $e) { // Failed to get the access token or user details. exit($e->getMessage()); } }
Change log
Please see CHANGELOG for more information on what has changed recently.
Testing
$ composer test
Contributing
Please see CONTRIBUTING and CONDUCT for details.
Security
If you discover any security related issues, please email roman+gh@sevastyanov.io instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
pizdata/oauth2-shopify 适用场景与选型建议
pizdata/oauth2-shopify 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 33.81k 次下载、GitHub Stars 达 14, 最近一次更新时间为 2017 年 03 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「authorization」 「client」 「oauth」 「oauth2」 「shopify」 「authorisation」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 pizdata/oauth2-shopify 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 pizdata/oauth2-shopify 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 pizdata/oauth2-shopify 相关的其它包
同方向 / 同关键字的高下载量 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
统计信息
- 总下载量: 33.81k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 15
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-03-29