0
votes

In the Shopify API documentation, the resource "User" is offered for those who pay for the Shopify Plus account. See below: https://help.shopify.com/api/reference/user#current Speaking to Shopify's support, because Shopify Plus user's are a minority, the shopify_api gem does not support these calls, so I have to build them myself. I've tried doing this by extending the current ShopifyAPI module and classes like so:

module ShopifyAPI
  class User < Base
    def self.current(options={})
      find(:one, options.merge({from: "/admin/users/current.json"}))
    end
  end
end

Then I call the new method like the following:

@user = ShopifyAPI::User.current

I get a "Not Found" error. If I check the logs of ActiveResource to see what call it is trying, strangely I get the following, which looks right:

I, [2017-02-24T13:14:19.278087 #4890]  INFO -- : GET https://mazer-3.myshopify.com:443/admin/users/current.json
I, [2017-02-24T13:14:19.278356 #4890]  INFO -- : --> 404 Not Found 22 (279.5ms)
I, [2017-02-24T13:14:19.279605 #4890]  INFO -- : Headers: {"Accept"=>"application/json", "User-Agent"=>"ShopifyAPI/4.3.5 ActiveResource/4.1.0 Ruby/2.3.1", "X-Shopify-Access-Token"=>"SOME_CHARACTERS_HERE_I_AM_NOT_SHOWING_TO_THE_PUBLIC"}
I, [2017-02-24T13:14:19.279680 #4890]  INFO -- : Response:
{"errors":"Not Found"}

If I copy that URL it is generating on the first line, https://mazer-3.myshopify.com:443/admin/users/current.json, and paste it in my browser while logged into Shopify, strangely it does gives me the current user, and a 200 success response code.

Is there something I am missing in configuring ActiveResource?

1

1 Answers

0
votes

There is no API endpoint activated for you to use, since the Shop is not a Plus shop... you cannot make your own endpoint calls and expect them to work, if Shopify has not authorized those calls. Internally, they turn on the Plus scopes... like User.

So you can consider it a good attempt, but you cannot fake out Shopify.