Skip to content

Commit

Permalink
remove the redirect uri param
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Hughes committed Mar 14, 2016
1 parent 4ba8e2d commit 6048161
Show file tree
Hide file tree
Showing 10 changed files with 3 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Expand Up @@ -9,6 +9,7 @@
* `ShopifyApp::Controller` has been removed. You’ll need to replace all includes of `ShopifyApp::Controller` with `ShopifyApp::LoginProtection`
* adds add_webhook generator to make it easier to add new webhooks to your app
* update the install generator to use standard rails generate arguments, usage has changed from `-api_key=your_key` to `--api_key your_key`
* remove the redirect uri - this is done automatically inside omniauth now

6.4.2
-----
Expand Down
2 changes: 1 addition & 1 deletion QUICKSTART.md
Expand Up @@ -56,7 +56,7 @@ bundle install
-------------------------------
```
use the keys from your app in the partners area
rails generate shopify_app -api_key=a366cbafaccebd2f615aebdfc932fa1c -secret=8750306a895b3dbc7f4136c2ae2ea293 -redirect_uri=https://<name>.herokuapp.com/auth/shopify/callback
rails generate shopify_app --api_key a366cbafaccebd2f615aebdfc932fa1c --secret 8750306a895b3dbc7f4136c2ae2ea293
git add .
git commit -m 'generated shopify app'
```
Expand Down
2 changes: 0 additions & 2 deletions README.md
Expand Up @@ -85,7 +85,6 @@ $ rails generate shopify_app:install --api_key <your_api_key> --secret <your_app
Other options include:
* `scope` - the Oauth access scope required for your app, eg 'read_products, write_orders'. For more information read the [docs](http://docs.shopify.com/api/tutorials/oauth)
* `embedded` - the default is to generate an [embedded app](http://docs.shopify.com/embedded-app-sdk), if you want a legacy non-embedded app then set this to false, `--embedded false`
* `redirect_uri` - the default is `http://localhost:3000/auth/shopify/callback` which will allow you to develop locally. You'll need to change it to match your domain for production.

You can update any of these settings later on easily, the arguments are simply for convenience.

Expand Down Expand Up @@ -128,7 +127,6 @@ The `install` generator places your Api credentials directly into the shopify_ap
ShopifyApp.configure do |config|
config.api_key = ENV['SHOPIFY_CLIENT_API_KEY']
config.secret = ENV['SHOPIFY_CLIENT_API_SECRET']
config.redirect_uri = "http://localhost:3000/auth/shopify/callback"
config.scope = 'read_customers, read_orders, write_products'
config.embedded_app = true
end
Expand Down
1 change: 0 additions & 1 deletion example/config/initializers/omniauth.rb
Expand Up @@ -2,6 +2,5 @@
provider :shopify,
ShopifyApp.configuration.api_key,
ShopifyApp.configuration.secret,
redirect_uri: ShopifyApp.configuration.redirect_uri,
scope: ShopifyApp.configuration.scope
end
1 change: 0 additions & 1 deletion example/config/initializers/shopify_app.rb
@@ -1,7 +1,6 @@
ShopifyApp.configure do |config|
config.api_key = ENV['SHOPIFY_CLIENT_API_KEY']
config.secret = ENV['SHOPIFY_CLIENT_API_SECRET']
config.redirect_uri = "http://localhost:3000/auth/shopify/callback"
config.scope = 'read_customers, read_orders, write_products'
config.embedded_app = true
end
2 changes: 0 additions & 2 deletions lib/generators/shopify_app/install/install_generator.rb
Expand Up @@ -9,14 +9,12 @@ class InstallGenerator < Rails::Generators::Base

class_option :api_key, type: :string, default: '<api_key>'
class_option :secret, type: :string, default: '<secret>'
class_option :redirect_uri, type: :string, default: 'http://localhost:3000/auth/shopify/callback'
class_option :scope, type: :string, default: 'read_orders, read_products'
class_option :embedded, type: :string, default: 'true'

def create_shopify_app_initializer
@api_key = options['api_key']
@secret = options['secret']
@redirect_uri = options['redirect_uri']
@scope = options['scope']

template 'shopify_app.rb', 'config/initializers/shopify_app.rb'
Expand Down
@@ -1,7 +1,6 @@
ShopifyApp.configure do |config|
config.api_key = "<%= @api_key %>"
config.secret = "<%= @secret %>"
config.redirect_uri = "<%= @redirect_uri %>"
config.scope = "<%= @scope %>"
config.embedded_app = <%= embedded_app? %>
end
@@ -1,5 +1,4 @@
provider :shopify,
ShopifyApp.configuration.api_key,
ShopifyApp.configuration.secret,
redirect_uri: ShopifyApp.configuration.redirect_uri,
scope: ShopifyApp.configuration.scope
1 change: 0 additions & 1 deletion lib/shopify_app/configuration.rb
Expand Up @@ -6,7 +6,6 @@ class Configuration
# `config/initializers/shopify_app.rb`
attr_accessor :api_key
attr_accessor :secret
attr_accessor :redirect_uri
attr_accessor :scope
attr_accessor :embedded_app
alias_method :embedded_app?, :embedded_app
Expand Down
4 changes: 1 addition & 3 deletions test/generators/install_generator_test.rb
Expand Up @@ -17,18 +17,16 @@ class InstallGeneratorTest < Rails::Generators::TestCase
assert_file "config/initializers/shopify_app.rb" do |shopify_app|
assert_match 'config.api_key = "<api_key>"', shopify_app
assert_match 'config.secret = "<secret>"', shopify_app
assert_match 'config.redirect_uri = "http://localhost:3000/auth/shopify/callback"', shopify_app
assert_match 'config.scope = "read_orders, read_products"', shopify_app
assert_match "config.embedded_app = true", shopify_app
end
end

test "creates the ShopifyApp initializer with args" do
run_generator %w(--api_key key --secret shhhhh --scope read_orders,write_products --redirect_uri http://example.com/auth/shopify/callback)
run_generator %w(--api_key key --secret shhhhh --scope read_orders,write_products)
assert_file "config/initializers/shopify_app.rb" do |shopify_app|
assert_match 'config.api_key = "key"', shopify_app
assert_match 'config.secret = "shhhhh"', shopify_app
assert_match 'config.redirect_uri = "http://example.com/auth/shopify/callback"', shopify_app
assert_match 'config.scope = "read_orders,write_products"', shopify_app
assert_match "config.embedded_app = true", shopify_app
end
Expand Down

0 comments on commit 6048161

Please sign in to comment.