2017 © Pedro Peláez
 

library shopify-oauth

Oauth 2.0 authentication for Shopify apps

image

codeinternetapplications/shopify-oauth

Oauth 2.0 authentication for Shopify apps

  • Wednesday, July 11, 2018
  • by code-nl
  • Repository
  • 0 Watchers
  • 0 Stars
  • 21 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 11 Versions
  • 0 % Grown

The README.md

Shopify Oauth connector

This packages enables you to make an OAuth connection with Shopify., (*1)

The package was originally written to use with Lumen. But it can also be used in combination with Laravel. Note that since it was made for Lumen the connector is stateless., (*2)

Installation

Use composer to install this package into your project, (*3)

composer require codeinternetapplications/shopify-oauth

Configuration

We tried to make it as easy as possible. Perform these steps to start:, (*4)

Copy config file

Copy the shopify_oauth.php config file to your config directory and make it available in the bootstrap/app.php file., (*5)

Adjust your keys in the config

Set your api_key, api_secret_key and base_url. Also adjust your scopes. You can use the .env file for this (see below), (*6)

Make sure your app supports Facades and Eloquent

In Lumen you will have to uncomment these lines in bootstrap/app.php:, (*7)

// $app->withFacades();

// $app->withEloquent();

Environment file

Put these variables in your .env file:, (*8)

SHOPIFY_APP_BASE_URL=https://url-to-your-app/
SHOPIFY_OAUTH_API_KEY=<API key obtained from the partner dashboard>
SHOPIFY_OAUTH_SECRET_KEY=<API Secret key obtained from the partner dashboard>

Also make sure that your APP_KEY is defined. Since we encrypt some data in the database Lumen/Laravel needs this key to encrypt it., (*9)

Register the ShopifyOauthServiceProvider

Register the ShopifyOauthServiceProvider in your application., (*10)

Run migrations

Run the migrations so you get the con_shops and con_shop_access_tokens table., (*11)

php artisan migrate

Usage of Middleware

Make sure that when you want to use the online token you will have to add the Middleware shopify-oauth-handler. It is advisable to use these middlewares in your routes: * shopify-hostname-validation * shopify-hmac-validation * shopify-oauth-handler, (*12)

For example:, (*13)


$router->group([ 'middleware' => [ 'shopify-hostname-validation', 'shopify-hmac-validation', 'shopify-oauth-handler', ] ], function() use ($router) { // Redirect to Polaris view $router->addRoute(['GET','POST','PUT'], '/[{page}]', function () { return view('polaris'); }); });

Execute scripts after installation

To install webhooks or trigger something right after the installation of the application you will have to implement an event listener into your app., (*14)

When the App is installed an event is triggered. You can listen to this event and implement custom actions such as: - Install webhooks - Trigger some data imports, (*15)

Create listener and listen

Open your bootstrap/app.php file and make sure that the EventServiceProvider is enabled., (*16)

Open the EventServiceProvider.php file and add these lines:, (*17)

    protected $listen = [
        'CodeInternetApplications\ShopifyOauth\Events\PostShopifyCallbackEvent' => [
            'App\Listeners\PostShopifyCallbackListener',  // assuming that your listener is located at App\Listeners\PostShopifyCallbackListener
        ],
    ];

Create a new local listener in your app/Listeners folder and add the scripts you want to perform. You can start with this template:, (*18)

<?php

namespace App\Listeners;

use CodeInternetApplications\ShopifyOauth\Events\PostShopifyCallbackEvent;

class PostShopifyCallbackListener
{
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param  PostShopifyCallbackEvent  $event
     * @return void
     */
    public function handle(PostShopifyCallbackEvent $event)
    {
        // log
        \Log::channel('stack')->info('PostShopifyCallbackEvent is triggered', []);
    }
}


The Versions

11/07 2018

dev-master

9999999-dev https://github.com/codeinternetapplications/shopify-oauth

Oauth 2.0 authentication for Shopify apps

  Sources   Download

MIT

The Requires

 

by Patrick Watzeels

laravel authentication lumen oauth shopify

11/07 2018

1.1.6

1.1.6.0 https://github.com/codeinternetapplications/shopify-oauth

Oauth 2.0 authentication for Shopify apps

  Sources   Download

MIT

The Requires

 

by Patrick Watzeels

laravel authentication lumen oauth shopify

04/07 2018

1.1.5

1.1.5.0 https://github.com/codeinternetapplications/shopify-oauth

Oauth 2.0 authentication for Shopify apps

  Sources   Download

MIT

The Requires

 

by Patrick Watzeels

laravel authentication lumen oauth shopify

04/07 2018

1.1.4

1.1.4.0 https://github.com/codeinternetapplications/shopify-oauth

Oauth 2.0 authentication for Shopify apps

  Sources   Download

MIT

The Requires

 

by Patrick Watzeels

laravel authentication lumen oauth shopify

04/07 2018

1.1.3

1.1.3.0 https://github.com/codeinternetapplications/shopify-oauth

Oauth 2.0 authentication for Shopify apps

  Sources   Download

MIT

The Requires

 

by Patrick Watzeels

laravel authentication lumen oauth shopify

21/06 2018

1.1.2

1.1.2.0 https://github.com/codeinternetapplications/shopify-oauth

Oauth 2.0 authentication for Shopify apps

  Sources   Download

MIT

The Requires

 

by Patrick Watzeels

laravel authentication lumen oauth shopify

21/06 2018

1.1.1

1.1.1.0 https://github.com/codeinternetapplications/shopify-oauth

Oauth 2.0 authentication for Shopify apps

  Sources   Download

MIT

The Requires

 

by Patrick Watzeels

laravel authentication lumen oauth shopify

21/06 2018

1.1.0

1.1.0.0 https://github.com/codeinternetapplications/shopify-oauth

Oauth 2.0 authentication for Shopify apps

  Sources   Download

MIT

The Requires

 

by Patrick Watzeels

laravel authentication lumen oauth shopify

07/06 2018

1.0.2

1.0.2.0 https://github.com/codeinternetapplications/shopify-oauth

Oauth 2.0 authentication for Shopify apps

  Sources   Download

MIT

The Requires

 

by Patrick Watzeels

laravel authentication lumen oauth shopify

04/06 2018

1.0.1

1.0.1.0 https://github.com/codeinternetapplications/shopify-oauth

Oauth 2.0 authentication for Shopify apps

  Sources   Download

MIT

The Requires

 

by Patrick Watzeels

laravel authentication lumen oauth shopify

04/06 2018

1.0.0

1.0.0.0

Oauth 2.0 authentication for Shopify public apps

  Sources   Download

MIT

The Requires

 

by Patrick Watzeels