Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.

Commit

Permalink
change from hostname to redirect_uri setting since we already have
Browse files Browse the repository at this point in the history
base_url
  • Loading branch information
Kevin Hughes committed Dec 14, 2015
1 parent 0abc53b commit 6cd2d2e
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
0.2.0
-----
* added a SHOPIFY_REDIRECT_URI env param for setting the redirect_uri (was breifly HOSTNAME)
* add versions to gemfile
* refactored the generator
* Changed install method to after_shopify_auth. Implementations of this method must now be idempotent as this will be called anytime the app is auth'd which may be due to just a lost session and not necessarily an install.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ This will create a new skeleton shopify-sinatra-app. The generator will create s

### Setting the app to use your Shopify API credentials

You'll need to create a Shopify Partner Account and a new application. You can make an account [here](http://www.shopify.ca/partners) and see this [tutorial](http://docs.shopify.com/api/the-basics/getting-started) for creating a new application.
You'll need to create a Shopify Partner Account and a new application. You can make an account [here](http://www.shopify.ca/partners) and see this [tutorial](http://docs.shopify.com/api/the-basics/getting-started) for creating a new application. This app uses the default redirect_uri from omniauth `<your domain>/auth/shopify/callback` so set it accordingly when creating your app.

Note - The shopify-sinatra-app creates an embedded app! You need change the embedded setting to `enabled` in the [Shopify Partner area](https://app.shopify.com/services/partners/api_clients) for your app. If you don't want your app to be embedded then remove the related code in `layout/application.erb` and delete the `layout/_top_bar.erb` file and the references to it in the other views.

Expand All @@ -66,8 +66,8 @@ After creating your new application you need to edit the `.env` file and add the
```
SHOPIFY_API_KEY=<your api key>
SHOPIFY_SHARED_SECRET=<your shared secret>
SHOPIFY_REDIRECT_URI="<your redirect_uri>"
SECRET=<generate a random string to encrypt credentials with>
HOSTNAME=<your apps url>
```

If your app has any other secret credentials you should add them to this file.
Expand Down
2 changes: 1 addition & 1 deletion bin/shopify-sinatra-app-generator
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class Generator
file = File.open(app_dir + '/.env', 'w')
file.write("SHOPIFY_API_KEY=your_api_key\n")
file.write("SHOPIFY_SHARED_SECRET=your_shared_secret\n")
file.write("SHOPIFY_REDIRECT_URI=your_redirect_uri\n")
file.write("SECRET=random_string_to_encrypt_credentials_with\n")
file.write("HOSTNAME=your_heroku_url\n")
file.close
end

Expand Down
8 changes: 5 additions & 3 deletions example/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
PATH
remote: /home/kevin/Dropbox/Shopify/shopify-sinatra-app
GIT
remote: git://github.com/kevinhughes27/shopify-sinatra-app.git
revision: b063ef10b38611e94b3f5e19d2af3e084d76888d
specs:
shopify-sinatra-app (0.2.0)
shopify-sinatra-app (0.1.5)
activesupport (~> 4.1.1)
attr_encrypted (~> 1.3.2)
omniauth-shopify-oauth2 (~> 1.1.11)
Expand Down Expand Up @@ -134,6 +135,7 @@ DEPENDENCIES
rack-test
rake
shopify-sinatra-app!
sinatra-activerecord
sinatra-twitter-bootstrap
sqlite3

Expand Down
4 changes: 2 additions & 2 deletions example/config/database.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
development:
adapter: sqlite3
database: db/shopify_app.sqlite3
database: db/development.sqlite3
pool: 5

production:
url: <%= ENV['DATABASE_URL'] %>

test:
adapter: sqlite3
database: "db/test.sqlite3"
Expand Down
2 changes: 1 addition & 1 deletion example/test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ENV['RACK_ENV'] = 'test'
ENV['SHOPIFY_REDIRECT_URI'] = 'http://localhost:4567'
ENV['SECRET'] = 'secret'
ENV['HOSTNAME'] = 'http://localhost:4567'

require 'minitest/autorun'
require 'rack/test'
Expand Down
4 changes: 2 additions & 2 deletions lib/sinatra/shopify-sinatra-app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ def self.registered(app)

app.set :api_key, ENV['SHOPIFY_API_KEY']
app.set :shared_secret, ENV['SHOPIFY_SHARED_SECRET']
app.set :redirect_uri, ENV['SHOPIFY_REDIRECT_URI']
app.set :secret, ENV['SECRET']
app.set :hostname, ENV['HOSTNAME']

app.use Rack::Flash, sweep: true
app.use Rack::MethodOverride
Expand All @@ -181,7 +181,7 @@ def self.registered(app)
provider :shopify,
app.settings.api_key,
app.settings.shared_secret,
redirect_uri: app.settings.hostname + "/auth/shopify/callback",
redirect_uri: app.settings.redirect_uri,

scope: app.settings.scope,

Expand Down

0 comments on commit 6cd2d2e

Please sign in to comment.