Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shopify Custom App - Distribution Links #1914

Open
asad-tech-dev opened this issue Oct 7, 2024 · 0 comments
Open

Shopify Custom App - Distribution Links #1914

asad-tech-dev opened this issue Oct 7, 2024 · 0 comments

Comments

@asad-tech-dev
Copy link

Overview

I have configured the shopify_app gem and maintained the shopify_app initializer. You can see the code block below, and it is working fine on the production site.

# config/initializers/shopify_app.rb

ShopifyApp.configure do |config|
  config.application_name = ENV['APP_NAME']
  config.api_key = ENV['API_KEY']
  config.secret = ENV['SECRET_KEY']
  config.scope = 'read_products, write_products'
  config.embedded_app = true
  config.reauth_on_access_scope_changes = true
  config.after_authenticate_job = false
  config.shop_session_repository = 'Shop'
  config.allow_jwt_authentication = true
  config.api_version = '2023-10'
end

I have now changed the entire UI in my application and want to offer the new version to select clients for beta testing. In the Shopify documentation, I found that we can create Custom Apps and manage distribution links for merchants, where we define the user's store and provide them with a link to test the app in real-time.
https://shopify.dev/docs/apps/launch/distribution

To handle this, I want to configure the api_key, secret, and application_name at runtime, so the configuration adjusts dynamically when detecting that it is a beta version of the application.

My goal is to define the new configurations in the controller and call the method using before_action.

Please guide me how can I achieve this task.

# app/controllers/authenticated_controller.rb

class AuthenticatedController < ApplicationController
  before_action :set_shopify_keys

  def set_shopify_keys
    ShopifyApp.configure do |config|
      config.application_name = 'New App Name'
      config.api_key = 'new-app-api-key'
      config.secret = 'new-app-secret'
      config.scope = 'read_products, write_products'
      config.embedded_app = true
      config.reauth_on_access_scope_changes = true
      config.after_authenticate_job = false
      config.shop_session_repository = 'Shop'
      config.allow_jwt_authentication = true
      config.api_version = '2023-10'
    end
  end
end

# Gemfile

gem 'shopify_app', '~> 18.1'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant