Why am I getting a 401 error with Shopify REST API OAuth?

Why am I getting a 401 error with Shopify REST API OAuth?

Rechunk
Shopify Partner
8 0 0

Hi there,

 

I implemented the OAuth flow that's described in the docs (without any library, just using plain python). It's working correctly. Well, at least for a while.

 

After some time (I'd guess a day) all the requests start throwing 401 errors.

 

I read about the difference between offline and online mode, and the default is supposed to be offline mode.

 

Could it be that I get online mode access tokens without actually specifying the mode?

 

I tried looking into how the access mode is specified, but didn't find anything.

 

This is the URL I redirect users to:

 

 

 

https://{shop}/admin/oauth/authorize?client_id={api_key}&scope={scopes}&redirect_uri={redirect_url}&state={nonce}&grant_options[]=per-user

 

 

 

And this is the code I use to receive the access token:

 

 

 

req = requests.post(
    f'https://{shop}/admin/oauth/access_token',
    {
        'client_id': 'xyz',
        'client_secret': 'xyz',
        'code': 'xyz'
    },
)

 

 

 

How can I specify the access mode here? Did I accidentally overwrite it?

 

Any help would be appreciated.

 

Thanks! 🙂

Replies 0 (0)