ERROR: MultiValueDictKeyError at /auth/shopify/callback 'code'

Topic summary

Main issue: Running the Shopify sample Django app locally (via ngrok) triggers a MultiValueDictKeyError at /auth/shopify/callback for key ‘code’.

Context/setup:

Observed error:

  • Internal Server Error on the callback route.
  • Django traceback shows KeyError: ‘code’ from django.utils.datastructures, indicating the request lacks the expected ‘code’ parameter.

Interpretation:

  • The callback appears to be missing the ‘code’ query parameter typically returned during OAuth after authorization.

Status/outcome:

  • User is asking what’s wrong; no solutions or follow-ups yet. Discussion remains open with no resolution.
Summarized with AI on January 17. AI used: gpt-5.

Hello, I am trying to run https://github.com/Shopify/sample-django-app on localhost using shopify, but I am getting error

MultiValueDictKeyError at /auth/shopify/callback

'code'

My .env file is located in root directory, it contains ACCESS_KEY, SECRET_KEY, API_URL and SCOPES. I also modified the APP URL and Allowed redirection URL(s) with ngrok url.

Here is the error on the server terminal:

Internal Server Error: /auth/shopify/callback
Traceback (most recent call last):
File “/home/tudor/.local/lib/python3.10/site-packages/django/utils/datastructures.py”, line 84, in getitem
list_ = super().getitem(key)
KeyError: ‘code’

What I am doing wrong? Thank you