2017 © Pedro Peláez
 

library oauth2-shopify

Shopify OAuth 2.0 Client Provider for The PHP League OAuth2-Client

image

pizdata/oauth2-shopify

Shopify OAuth 2.0 Client Provider for The PHP League OAuth2-Client

  • Friday, April 14, 2017
  • by davex69
  • Repository
  • 2 Watchers
  • 9 Stars
  • 349 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 4 Versions
  • 454 % Grown

The README.md

Shopify OAuth 2.0 Client Provider

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads, (*1)

Shopify OAuth 2.0 Client Provider., (*2)

Install

Via Composer, (*3)

``` bash $ composer require pizdata/oauth2-shopify, (*4)


## Usage ``` php $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., (*5)

Testing

bash $ composer test, (*6)

Contributing

Please see CONTRIBUTING and CONDUCT for details., (*7)

Security

If you discover any security related issues, please email roman+gh@sevastyanov.io instead of using the issue tracker., (*8)

Credits

License

The MIT License (MIT). Please see License File for more information., (*9)

The Versions

14/04 2017

dev-master

9999999-dev https://github.com/pizdata/oauth2-shopify-php

Shopify OAuth 2.0 Client Provider for The PHP League OAuth2-Client

  Sources   Download

MIT

The Requires

 

The Development Requires

authorization oauth client oauth2 authorisation shopify pizdata

29/03 2017

v1.0.1

1.0.1.0 https://github.com/pizdata/oauth2-shopify-php

Shopify OAuth 2.0 Client Provider for The PHP League OAuth2-Client

  Sources   Download

MIT

The Requires

 

The Development Requires

authorization oauth client oauth2 authorisation shopify pizdata

29/03 2017

v1.0.0

1.0.0.0 https://github.com/pizdata/oauth2-shopify-php

Shopify OAuth 2.0 Client Provider for The PHP League OAuth2-Client

  Sources   Download

MIT

The Requires

 

The Development Requires

authorization oauth client oauth2 authorisation shopify pizdata

28/03 2017

v0.1.0

0.1.0.0 https://github.com/pizdata/oauth2-shopify-php

Shopify OAuth 2.0 Client Provider for The PHP League OAuth2-Client

  Sources   Download

MIT

The Requires

 

The Development Requires

authorization oauth client oauth2 authorisation shopify pizdata