Generating Shopify authorization credentials to test a Shopify client library.

When you're building or testing a Shopify client library such as ShopifySharp, you'll eventually need an API key and an access token for a real Shopify store. The API key is an easy thing to get if you've already got your own Shopify app — you're assigned a unique key for every Shopify app you create.

Generating an access token, though, is a little bit more involved than that. An access token is typically only generated during the regular app authorization process that each user has to go through when installing a Shopify app. That makes it difficult to discover and use an access token without creating your own Shopify app (if you haven't already), manually installing it to a store and then write some code to authorize the installation and spit out the access token to your developer console.

All of that is time consuming and far from ideal. To complicate things further, the access token will be invalidated once the app has been uninstalled from the store.

Luckily, there's an easier way to get an access token when you're testing Shopify client libraries.

All you'll need to do is create a Shopify developer account (which you'll need anyway if you're building a Shopify app), then create a dev shop and what's called a "private app" for that dev shop. A private app differs from a normal, public app in that it only exists on the shop you created it on. It cannot be installed to any other shop and it's granted full permissions.

For this reason, a private app on a dev shop is perfect for testing Shopify client libraries.

(N.B. this also works to test your own public Shopify app by ensuring that one of your test user accounts always has access to a store. However, you'll need to remember that the private app access token is given full permissions, something that your real app may not have.)

Here's what you need to do:

  1. To get started, head over to https://app.shopify.com/services/partners/signup and create your Shopify developer account.
  2. Navigate to your developer dashboard at https://app.shopify.com/services/partners and click the Development Shops link on the left NavBar.
  3. Click the "Create a new development store" at the top right of the page and go through the quick form to get it set up. For our purposes, we only need to create an online store, so make sure you select the "Online store" option, not "Retail store" or "Online and retail store".
  4. Once your store has been created, log in to it at my-store-url.myshopify.com/admin and navigate to Apps on the left NavBar, then click the Private Apps button at the top right of the page.
  5. Create a new private app!

Once you've done all that and created your new private app, you should be redirected to a screen that contains all of the necessary credential information for the app. It looks like this:

imgur

Shopify doesn't make it obvious, but the Password displayed here is actually an access token. All you have to do is copy that access token (again, labeled as "Password" in a private app) and your new dev shop's *.myshopify.com URL and use them in your Shopify client library for testing.

If you're looking for a high quality .NET Shopify library, give ShopifySharp a whirl.


Learn how to build rock solid Shopify apps with C# and ASP.NET!

Did you enjoy this article? I wrote a premium course for C# and ASP.NET developers, and it's all about building rock-solid Shopify apps from day one.

Enter your email here and I'll send you a free sample from The Shopify Development Handbook. It'll help you get started with integrating your users' Shopify stores and charging them with the Shopify billing API.

We won't send you spam. Unsubscribe at any time.