Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
470 views
in Technique[技术] by (71.8m points)

django rest framework - Gettings access token from ShopifyAPI python library

I am trying to build a public app for shopify.

I have registered the app in my patners.shopify and have access to my Public and Secret API keys.

I have a django python script(end point in my views.py) as seen below

@csrf_exempt
@require_POST
def ShopifyCallbackUrl(request):
    try:
        API_KEY = "xxxxxxxxxxxxxxxxxxxxxxxxxx"
        API_SECRET = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

        shopify.Session.setup(api_key=API_KEY, secret=API_SECRET)

        shop_url = "xxxx-test-store.myshopify.com"
        api_version = '2020-10'
        state = binascii.b2a_hex(os.urandom(15)).decode("utf-8")
        redirect_uri = "https://webhook.site/e12c1926-f47b-45b4-bc59-0a3f69999f82" #new webhook session
        scopes = ['read_products', 'read_orders']

        newSession = shopify.Session(shop_url, api_version)
        auth_url = newSession.create_permission_url(scopes, redirect_uri, state)
      
        session = shopify.Session(shop_url, api_version)

    except PermissionDenied:
        return HttpResponse('PermissionDenied', status=status.HTTP_204_NO_CONTENT)
    return HttpResponse('OK :-)', status=status.HTTP_200_OK)

at the very least, the code works when I send a post request. However, I am not getting a response on my return URL.

Please advise me what I might have missed.

  1. I have downloaded the ShopifyAPI using pip install, not added to INSTALLED_APPS in settings.py
  2. The return URL works when I sent requests so it should work here(I believe)
question from:https://stackoverflow.com/questions/65897914/gettings-access-token-from-shopifyapi-python-library

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...