Data Retrieval not happening while trying by using Partners account

Data Retrieval not happening while trying by using Partners account

Pradeep_V
Visitor
1 0 0

Hello I am trying to retrieve the data from the marchant account by using the partners account with the below python code. I am not getting any Authorization code. Please resolve this or suggest how to do that.

import shopify
import binascii
import os

# Set up the Shopify API session
API_KEY = '22434e0c8d10dcd3f72f187c1d7149e5'
API_SECRET = 'b725127b7309553d0489f40a35d27138'
APP_NAME = 'Online Store'
SHOP_NAME = '58402c.myshopify.com'
API_VERSION = '2023-04'
REDIRECT_URI = 'https://58402c.myshopify.com/oauth/callback'

# Set up the session with your API Key and Secret Key
shopify.Session.setup(api_key=API_KEY, secret=API_SECRET)

# Set up the authentication URL
session = shopify.Session(SHOP_NAME, API_VERSION)
pos = binascii.b2a_hex(os.urandom(15)).decode("utf-8")
scopes = ['read_products', 'read_orders']
auth_url = session.create_permission_url(scopes, REDIRECT_URI, pos)
if 'state' in auth_url:
auth_url=auth_url.replace('state','fstate')

# Redirect the user to the authentication URL and prompt them to accept the permissions
print(f"Please go to this URL to authenticate with Shopify:\n{auth_url}\n")

# Wait for the user to authenticate and then enter the code parameter provided in the redirected URL
code = input("Please enter the code parameter from the redirected URL: ")

# Request an access token using the code parameter
session.request_token({'code': code})

# Activate the session and access the products table
shopify.ShopifyResource.activate_session(session)
products = shopify.Product.find()

# Print out the list of products
for product in products:
print(product.title)

# Clear the session
shopify.ShopifyResource.clear_session()

Replies 0 (0)