My app keeps redirecting to login
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 1.9k
- Forks
- 739
- Avg merge
- 21h 2m
- Merged PRs (30d)
- 1
Description
v22.5.2
There's heading in the Troubleshooting doc for this but no content! https://github.com/Shopify/shopify_app/blob/main/docs/Troubleshooting.md
Logging shows this as the issue:
Filter chain halted as :login_on_scope_changes rendered or redirected
Yet from the console ShopifyApp.configuration.shop_access_scopes_strategy.update_access_scopes? returns false.
Cookes are set after logging in but, if the host and shop query string parameters are not set, one is redirected to login.
Config:
ShopifyApp.configure do |config|
config.application_name = "Total Headache"
config.old_secret = ""
config.scope = "read_products"
# read_all_orders need shopify approval before we can use
config.scope = '...'
config.embedded_app = false
config.new_embedded_auth_strategy = false
config.after_authenticate_job = false
config.api_version = "2025-07"
config.shop_session_repository = "Shop"
config.log_level = :debug
config.reauth_on_access_scope_changes = true
config.webhooks = []
config.api_key = ENV.fetch('SHOPIFY_API_KEY', '').presence
config.secret = ENV.fetch('SHOPIFY_API_SECRET', '').presence
# You may want to charge merchants for using your app. Setting the billing configuration will cause the Authenticated
# controller concern to check that the session is for a merchant that has an active one-time payment or subscription.
# If no payment is found, it starts off the process and sends the merchant to a confirmation URL so that they can
# approve the purchase.
#
# Learn more about billing in our documentation: https://shopify.dev/apps/billing
# config.billing = ShopifyApp::BillingConfiguration.new(
# charge_name: "My app billing charge",
# amount: 5,
# interval: ShopifyApp::BillingConfiguration::INTERVAL_EVERY_30_DAYS,
# currency_code: "USD", # Only supports USD for now
# trial_days: 0,
# test: !ENV['SHOPIFY_TEST_CHARGES'].nil? ? ["true", "1"].include?(ENV['SHOPIFY_TEST_CHARGES']) : !Rails.env.production?
# )
if defined? Rails::Server
raise('Missing SHOPIFY_API_KEY. See https://github.com/Shopify/shopify_app#requirements') unless config.api_key
raise('Missing SHOPIFY_API_SECRET. See https://github.com/Shopify/shopify_app#requirements') unless config.secret
end
end
Rails.application.config.after_initialize do
if ShopifyApp.configuration.api_key.present? && ShopifyApp.configuration.secret.present?
ShopifyAPI::Context.setup(
api_key: ShopifyApp.configuration.api_key,
api_secret_key: ShopifyApp.configuration.secret,
api_version: ShopifyApp.configuration.api_version,
host: ENV.fetch('HOST'),
scope: ShopifyApp.configuration.scope,
is_private: !ENV.fetch('SHOPIFY_APP_PRIVATE_SHOP', '').empty?,
is_embedded: ShopifyApp.configuration.embedded_app,
log_level: :debug,
logger: Rails.logger,
private_shop: ENV.fetch('SHOPIFY_APP_PRIVATE_SHOP', nil),
user_agent_prefix: "ShopifyApp/#{ShopifyApp::VERSION}"
)
ShopifyApp::WebhooksManager.add_registrations
end
end
And, controllers:
class AuthenticatedController < ApplicationController
include ShopifyApp::EnsureHasSession
end
class TotalHeadachesController < AuthenticatedController
include ShopifyApp::ShopAccessScopesVerification
end
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with docs/Troubleshooting.md and trace the authentication flow from ShopifyApp::EnsureHasSession through ShopifyApp::ShopAccessScopesVerification, using the reported log message and configuration as reproduction details. Done should identify why requests without host and shop are redirected and either correct the behavior or document the required configuration and expected flow.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rails, ruby
- Domain
- authentication, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100