title: Rails omniauth-shopify-oauth2: "[API] Invalid API key or access token (unrecognized login or wrong password)" from console
body: <p>I set up shopify auth (omniauth-shopify-oauth2 gem) for my rails 3.2.6 app.</p>
  
  <p>It works fine when routed from a web page (to the following controller#action)</p>
  
  <pre><code>class ShopifyController &lt; ApplicationController
    ...
    def login
      redirect_to "/auth/shopify?shop=#{current_retailer.primary_host_name}"
    end
  </code></pre>
  
  <p>It redirects me to shop login and, once I am logged in, redirects back to success callback. All good (see SERVER LOG SUCCESS below).</p>
  
  <p>But when I try to do pretty much the same from the rails console:</p>
  
  <pre><code>irb(main):001:0&gt; RestClient.get 'http://localhost:3000/auth/shopify?shop=vinehillposters.myshopify.com'
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>RestClient::Unauthorized: 401 Unauthorized: &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;hash&gt;
    &lt;errors&gt;[API] Invalid API key or access token (unrecognized login or wrong password)&lt;/errors&gt;
  &lt;/hash&gt;
  </code></pre>
  
  <p>see SERVER LOG FAIL below</p>
  
  <p><br></p>
  
  <p><strong>SERVER LOG SUCCESS:</strong></p>
  
  <pre><code>Processing by ShopifyController#login as HTML
  ... AR stuff snipped ...
  Redirected to http://localhost:3000/auth/shopify?shop=vinehillposters.myshopify.com
  Completed 302 Found in 93ms (ActiveRecord: 1.6ms)
  (shopify) Setup endpoint detected, running now.
  (shopify) Request phase initiated.
  "https://vinehillposters.myshopify.com/admin/oauth/authorize?response_type=code&amp;client_id=44dd9799fbc268c36ef609f0c2386b8c&amp;redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fauth%2Fshopify%2Fcallba
  ck&amp;scope=read_orders"
  
  Started GET "/auth/shopify?shop=vinehillposters.myshopify.com" for 127.0.0.1 at 2012-10-30 11:24:21 +0000
  (shopify) Setup endpoint detected, running now.
  (shopify) Callback phase initiated.
  
  Started GET "/auth/shopify/callback?code=c8c6696ed347e37324d2d62ec203457b&amp;shop=vinehillposters.myshopify.com&amp;timestamp=1351596261&amp;signature=e6324b041d6a6ed1e07719a8909d70f7" for 127.0.0.1 at 
  2012-10-30 11:24:21 +0000
  Processing by ShopifyController#auth_callback as HTML
  ...
  </code></pre>
  
  <p><br>
  <strong>SERVER LOG FAILURE:</strong></p>
  
  <pre><code>(shopify) Setup endpoint detected, running now.
  (shopify) Request phase initiated.
  "https://vinehillposters.myshopify.com/admin/oauth/authorize?response_type=code&amp;client_id=44dd9799fbc268c36ef609f0c2386b8c&amp;redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fauth%2Fshopify%2Fcallback&amp;scope=read_orders"
  
  
  Started GET "/auth/shopify?shop=vinehillposters.myshopify.com" for 127.0.0.1 at 2012-10-30 11:24:54 +0000
  </code></pre>
  
  <p>You may have noticed that I print out the request_phase url right before it gets redirected to shopify (after <code>(shopify) Request phase initiated.</code>). It is the same in both cases. Except in one case it returns success and in another it is 401.</p>
  
  <p>So, what am I doing wrong?</p>