NEWBIE QUESTION: how to generate an Access Token for ShopifySharp

Solved
mbhvl
Tourist
4 1 0

I'm a very experienced developer in other fields -- but completely new to Shopify & ShopifySharp.  Please don't bite if this is a dumb question - I've been searching for an answer for several hours and am out of ideas.

I'm following the example C# ShopifySharp code here:

https://github.com/nozzlegear/ShopifySharp#customers

Retrieving a customer

var service =  new CustomerService(myShopifyUrl, shopAccessToken);
var customer = await service.GetAsync(customerId);

 

I am trying to find the right value to pass in as shopAccessToken.

The trouble is, the instructions here https://nozzlegear.com/shopify/generating-shopify-authorization-credentials show this screenshot of the Shopify App admin page:

WNJHMzt.png

But this does not match what I see in my admin page at https://partners.shopify.com/[PARTNERNUMBER]/apps/[APPNUMBER]/edit:

Untitled.png

I've tried passing in the "API secret key" but this (predictably) threw an exception saying the token was wrong.

 

I've looked really hard for how to generate an access token and all I've found is something relevant to building a PHP web app (I think) here:

https://www.shopify.co.uk/partners/blog/17056443-how-to-generate-a-shopify-api-token

 

But I'm developing from C# and just want to use the ShopifySharp API directly (to upload Customers, Items and historical Orders & Transactions).

So I'm out of ideas.

How can I generate the token I need?  What I am not understanding here?

As I said I'm a newbie on Shopify programming so any guidance would be warmly received.

Thanks...

 

 

0 Likes
policenauts
Trailblazer
190 9 49

I haven't used this before, but according to their documentation this should work for private apps (which is what it looks like you're trying to use): 

 

 

var service = new ShopifySharp.OrderService("mydomain.myshopify.com", "PRIVATE APP PASSWORD HERE"). 

 

 

 

Can you confirm you're not adding an http:// or https:// to your shopify domain? You're also probably better off raising this as a github issue or doing a search for issues within that repo.

0 Likes
mbhvl
Tourist
4 1 0

Yes, I can confirm for sure that I provide the URL without an http:// or https:// prefix.

The error message is very specific and says the authorisation token is wrong.  I will supply it here once back at desk.

0 Likes
mbhvl
Tourist
4 1 0

I have double-checked my C# code and I have:

string myShopifyUrl = "[SHOPNAME].myshopify.com";     // NO http: or https: prefix
string shopAccessToken = "[32CHARACTERCODE]";         // have tried several variants (different codes from different part of my Shopify private app's details

Actual values of [SHOPNAME] and [32CHARACTERCOD] obfuscated here for privacy.

The error message I get is:

ShopifyException: (401 Unauthorized) [API] Invalid API key or access token (unrecognized login or wrong password)

0 Likes
mbhvl
Tourist
4 1 0

This is an accepted solution.

OK I found the answer.

The new version of Shopify has crept ahead of ShopifySharp.  No bad; a one-man team can't keep up with a huge corporation.

And the updated guidance on ShopifySharp is coming out in due course.

0 Likes