Getting Token for Python

Highlighted
New Member
8 0 0

Hi all,

 

Background:

Novice coder here, trying to build a private app for my back end using some python scripting.


What I've done so far:

I'm following the steps in https://github.com/Shopify/shopify_python_api , laying out the code in the "Getting Started" section.

 

I understand the code in 1,2,5,6,7 but don't really understand what 3-4 are referring to. How can I get these access tokens? I understand it has something to do with OAuth.

 

I watched this video: https://www.youtube.com/watch?v=OgV02llCIeE and it seems to use ngrok and Flask.

 

Question:

Correct my understanding - once I get the "code", then I can just copy the string in or put it in a config file? Is this what the token is?

How are steps 3-4 to be coded in python?

Can I achieve steps 3-4 without the use of Flask or ngrok? I'm looking to build a simple script without any additional software, if possible.

 

 

Appreciate the help. Development is not my main cup of tea, but I do get my feet wet occasionally.

Once I get past the authentication, I should be good!

 

Thanks!

0 Likes
Shopify Staff
Shopify Staff
240 32 37

Hey @DL7,

 

For a private app, you can skip steps 3, 4 & 5:

 

For a private App you just need to set the base site url as follows:

shop_url = "https://%s:%s@SHOP_NAME.myshopify.com/admin/api/%s" % (API_KEY, PASSWORD, API_VERSION)
shopify.ShopifyResource.set_site(shop_url)

That's it you're done, skip to step 6 and start using the API!

 

0 Likes