Quantcast
Channel: Opinion: Shopify Community - Shopify APIs & SDKs
Viewing all articles
Browse latest Browse all 25503

Walther Diechmann commented on how do I get past the localhost:3000/login step when building an app

$
0
0

Chris and Kevin,

I do find the shopify_app and shopify_api gems useful - most certainly - and I would not successfully be using the shopify console without.

But, what eludes me is, how do I get from successfully using the shopify command to using the rails console doing:

Product.create( name: 'r2d2' )

in an otherwise totally "standard" Rails 4.0.0 with Devise 3.2.2 on Ruby 2.0.0-p247 on a Mac (lazely not surfing the Mavericks yet) <:)

My Product class looks like this:

class Product < ActiveRecord::Base
  before_save :save_shopify

  def save_shopify
    if new_record?
      sp = ShopifyAPI::Product.new()
    else
      sp = ShopifyAPI::Product.find(shopify_id)
    end
    raise 'No Spopify Access - investigate!' unless sp
    update_shopify_product_details sp
  end
  
  def update_shopify_product_details sp
    true
  end
  
end

and in the initialization 'department' I have

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :shopify, 
           ShopifyApp.configuration.api_key, 
           ShopifyApp.configuration.secret,

           # Example permission scopes - see http://docs.shopify.com/api/tutorials/oauth for full listing
           :scope => 'read_orders, write_products',

           :setup => lambda {|env| 
                       params = Rack::Utils.parse_query(env['QUERY_STRING'])
                       site_url = "https://#{params['shop']}&quot;
                       env['omniauth.strategy'].options[:client_options][:site] = site_url
                     }
end

and finally I have my Gemfile with

group :development do
  gem 'shopify_app'

and my settings in application.rb - (all done by the generator actually)


module NaniDev
  class Application < Rails::Application
    
    # Shopify API connection credentials:
    config.shopify.api_key = '99a1742816676a5fee533db6ec10a931'
    config.shopify.secret = '48c123e003ca21cdd124478dd699622e'

 

 


Viewing all articles
Browse latest Browse all 25503

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>