How do I use shopify-api-console with a public app in development?

Solved
Marc_Gayle
Excursionist
14 2 1

The instructions to setup Shopify-API Console assumes you will be making a Private App, and so the API Key info is about a Private App only.

However, I am building a public app and it won't accept my secret key as the password and I can't figure out how to generate a password for the public app credentials.

This is what I see when I try to access it with the secret key as password.

[5] pry(main)> Product.count
E, [2021-04-27T19:27:57.462337 #19844] ERROR -- : GET https://myapp.myshopify.com:443/admin/api/2021-04/products/count.json
E, [2021-04-27T19:27:57.462511 #19844] ERROR -- : --> 401 Unauthorized 89 (332.3ms)
ActiveResource::UnauthorizedAccess: Failed.  Response code = 401.  Response message = Unauthorized ([API] Invalid API key or access token (unrecognized login or wrong password)).

How do I configure shopify-api-console to work for a public app?

0 Likes
CalD
Shopify Staff
Shopify Staff
128 15 18

Hey @Marc_Gayle,

After you install a public app on a store, the access_token generated can be used as the API password (e.g. for the X-Shopify-Access-Token header). Check out this tutorial for more info: https://shopify.dev/tutorials/authenticate-with-oauth 

CalD | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

0 Likes
Marc_Gayle
Excursionist
14 2 1

Hi @CalD,

   So I already have a public app installed in my development store. Where do I find the access_token?

The linked article isn't clear. I created a Vanilla Rails + Turbolinks app following this tutorial and my code base looks almost identical to this sample app.

I also tried setting up my Ruby API Console using this tutorial but I keep getting an authentication error.

I would love some more clarity with precisely how to get it all set up.

Thanks!

0 Likes
Marc_Gayle
Excursionist
14 2 1

Hi @CalD or anyone else that can help me.

Just bumping this.

I am still unable to use shopify-api-console with my public Rails app.

0 Likes
Marc_Gayle
Excursionist
14 2 1

This is an accepted solution.

After significant head bashing, and very little support from Shopify, I finally figured it out.

The Shopify-Api-Console documentation is unclear in a very crucial respect.

Basically the way it works is that in order for me to get 'Shopify-Api-Console' access, I need to create a private app on the store I want api-console access to and then use those credentials (API Key & Password) to grant my local shopify-api-console instance access to the Shopify store via the private app.

So even though I have a Public App installed on my store, I also need to install a Private App dedicated to the Shopify API Console separately. Based on the way Rails works, I assumed that the console would give me console access via the 'Public App' which is why I couldn't understand how to achieve this issue.

So, to fix this for others, I suggest improving the documentation in the guide from this:

Open up your development store and populate it with Orders, Customers, Products, etc. — whatever you may need to properly develop your app.

To generate a private API key, go to your development store and click on the Apps tab. At the bottom of the screen, click on the Manage private apps link.

Once you have your API key, install the Shopify API and Shopify API Console Ruby gems.

 

To something like this:

Open up your development store and populate it with Orders, Customers, Products, etc. — whatever you may need to properly develop your app.

To get Shopify API Console access, what you will have to do is create a dedicated Private App within your development store (along with the permissions you need for the console) and use the credentials for that specific Private App when setting up your 'Shopify API Console'.

To generate a private API key, go to your development store and click on the Apps tab. At the bottom of the screen, click on the Manage private apps link. Create a private app and select the permissions you want. Once the app is created, you will see your API key & Password.

Once you have your API key, install the Shopify API and Shopify API Console Ruby gems.

 

0 Likes