RailsテンプレートからのShopifyアプリの開発<中止>

Shopify

はじめに

Shopifyパートナー画面からアプリを登録

アプリメニューから「Create app manually」を選択し、名前だけを入力し、アプリを作成する

名前:my_rails_app_1

Rails アプリを作成

以下のコマンドを実行

% rails new my_rails_app_1
% cd my_rails_app_1
% bundle add shopify_app
% bundle add dotenv-rails
% bundle install

.env ファイルを作成し、以下を追加

HOST=http://localhost:3000
SHOPIFY_API_KEY=<Your Shopify API key>
SHOPIFY_API_SECRET=<Your Shopify API secret>

以下のコマンドを実行

% rails generate shopify_app

================================================
=> Upcoming changes in v23.0:
* 'CallbackController::perform_after_authenticate_job' and related methods 'install_webhooks', 'perform_after_authenticate_job'
* are deprecated and  will be removed from CallbackController in the next major release. If you need to customize
* post authentication tasks, see https://github.com/Shopify/shopify_app/blob/main/docs/shopify_app/authentication.md#post-authenticate-tasks

* ShopifyApp::JWTMiddleware will be removed, use ShopifyApp::WithShopifyIdToken instead.
================================================
    generate  shopify_app:add_app_uninstalled_job
       rails  generate shopify_app:add_app_uninstalled_job 
================================================
=> Upcoming changes in v23.0:
* 'CallbackController::perform_after_authenticate_job' and related methods 'install_webhooks', 'perform_after_authenticate_job'
* are deprecated and  will be removed from CallbackController in the next major release. If you need to customize
* post authentication tasks, see https://github.com/Shopify/shopify_app/blob/main/docs/shopify_app/authentication.md#post-authenticate-tasks

* ShopifyApp::JWTMiddleware will be removed, use ShopifyApp::WithShopifyIdToken instead.
================================================
      create  app/jobs/app_uninstalled_job.rb
    generate  shopify_app:add_privacy_jobs
       rails  generate shopify_app:add_privacy_jobs 
================================================
=> Upcoming changes in v23.0:
* 'CallbackController::perform_after_authenticate_job' and related methods 'install_webhooks', 'perform_after_authenticate_job'
* are deprecated and  will be removed from CallbackController in the next major release. If you need to customize
* post authentication tasks, see https://github.com/Shopify/shopify_app/blob/main/docs/shopify_app/authentication.md#post-authenticate-tasks

* ShopifyApp::JWTMiddleware will be removed, use ShopifyApp::WithShopifyIdToken instead.
================================================
      create  app/jobs/customers_data_request_job.rb
      create  app/jobs/shop_redact_job.rb
      create  app/jobs/customers_redact_job.rb
    generate  shopify_app:install 
       rails  generate shopify_app:install  
================================================
=> Upcoming changes in v23.0:
* 'CallbackController::perform_after_authenticate_job' and related methods 'install_webhooks', 'perform_after_authenticate_job'
* are deprecated and  will be removed from CallbackController in the next major release. If you need to customize
* post authentication tasks, see https://github.com/Shopify/shopify_app/blob/main/docs/shopify_app/authentication.md#post-authenticate-tasks

* ShopifyApp::JWTMiddleware will be removed, use ShopifyApp::WithShopifyIdToken instead.
================================================
      create  config/initializers/shopify_app.rb
      create  config/initializers/session_store.rb
      create  app/views/layouts/embedded_app.html.erb
      create  app/views/layouts/_flash_messages.html.erb
      create  app/javascript/lib/shopify_app.js
      create  app/javascript/lib/flash_messages.js
      append  config/importmap.rb
       route  mount ShopifyApp::Engine, at: '/'
      insert  config/environments/development.rb
      insert  config/environments/development.rb
      insert  config/environments/development.rb
      insert  config/environments/development.rb
    generate  shopify_app:shop_model 
       rails  generate shopify_app:shop_model  
================================================
=> Upcoming changes in v23.0:
* 'CallbackController::perform_after_authenticate_job' and related methods 'install_webhooks', 'perform_after_authenticate_job'
* are deprecated and  will be removed from CallbackController in the next major release. If you need to customize
* post authentication tasks, see https://github.com/Shopify/shopify_app/blob/main/docs/shopify_app/authentication.md#post-authenticate-tasks

* ShopifyApp::JWTMiddleware will be removed, use ShopifyApp::WithShopifyIdToken instead.
================================================
      create  app/models/shop.rb
      create  db/migrate/20240730092047_create_shops.rb
It is highly recommended that apps record the access scopes granted by merchants during app installation. See app/models/shop.rb to modify how access scopes are stored and retrieved.

[WARNING] You will need to update the access_scopes accessors in the Shop model to allow shopify_app to store and retrieve scopes when going through OAuth.

The following migration will add an `access_scopes` column to the Shop model. Do you want to include this migration? [y/n]
 y
      create  db/migrate/20240730092059_add_shop_access_scopes_column.rb
        gsub  config/initializers/shopify_app.rb
      create  test/fixtures/shops.yml
    generate  shopify_app:authenticated_controller
       rails  generate shopify_app:authenticated_controller 
================================================
=> Upcoming changes in v23.0:
* 'CallbackController::perform_after_authenticate_job' and related methods 'install_webhooks', 'perform_after_authenticate_job'
* are deprecated and  will be removed from CallbackController in the next major release. If you need to customize
* post authentication tasks, see https://github.com/Shopify/shopify_app/blob/main/docs/shopify_app/authentication.md#post-authenticate-tasks

* ShopifyApp::JWTMiddleware will be removed, use ShopifyApp::WithShopifyIdToken instead.
================================================
      create  app/controllers/authenticated_controller.rb
    generate  shopify_app:home_controller 
       rails  generate shopify_app:home_controller  
================================================
=> Upcoming changes in v23.0:
* 'CallbackController::perform_after_authenticate_job' and related methods 'install_webhooks', 'perform_after_authenticate_job'
* are deprecated and  will be removed from CallbackController in the next major release. If you need to customize
* post authentication tasks, see https://github.com/Shopify/shopify_app/blob/main/docs/shopify_app/authentication.md#post-authenticate-tasks

* ShopifyApp::JWTMiddleware will be removed, use ShopifyApp::WithShopifyIdToken instead.
================================================
      create  app/controllers/home_controller.rb
    generate  shopify_app:products_controller
       rails  generate shopify_app:products_controller 
================================================
=> Upcoming changes in v23.0:
* 'CallbackController::perform_after_authenticate_job' and related methods 'install_webhooks', 'perform_after_authenticate_job'
* are deprecated and  will be removed from CallbackController in the next major release. If you need to customize
* post authentication tasks, see https://github.com/Shopify/shopify_app/blob/main/docs/shopify_app/authentication.md#post-authenticate-tasks

* ShopifyApp::JWTMiddleware will be removed, use ShopifyApp::WithShopifyIdToken instead.
================================================
      create  app/controllers/products_controller.rb
       route  get '/products', :to => 'products#index'
      create  app/views/home/index.html.erb
       route  root :to => 'home#index'

以下のコマンドを実行

% rails db:migrate

ngrok管理画面のYour AuthTokenメニューからコマンドを取得し、実行する

ngrok config add-authtoken <Your AuthToken>

ngrok管理画面のDomainメニューで固定ドメインを追加する

例)XXXXX.ngrok-free.app

Shopifyパートナー管理画面の開発中のアプリでドメインを登録する

  • AppURL: https://evidently-prompt-sloth.ngrok-free.app/
  • Allow Redirect URL: https://evidently-prompt-sloth.ngrok-free.app/api/auth

関連記事

カテゴリー

アーカイブ

Lang »