Files
Payme-Shopify-Integration/app/utils/get_token.py
Abdulaziz Axmadaliyev 92165edbe6 Initial commit
2026-02-26 16:35:47 +05:00

30 lines
932 B
Python

import webbrowser
import httpx
from urllib.parse import urlparse, parse_qs
CLIENT_ID = "5811038f7c170b60b93fca3727545e6f"
CLIENT_SECRET = input("Paste your Client Secret: ").strip()
STORE = "cx0du9-sq.myshopify.com"
auth_url = (
f"https://{STORE}/admin/oauth/authorize"
f"?client_id={CLIENT_ID}"
f"&scope=read_orders,write_orders,read_draft_orders,write_draft_orders,read_customers"
f"&redirect_uri=https://example.com"
f"&state=abc123"
)
print("\nOpening browser — click Allow...")
webbrowser.open(auth_url)
redirect_url = input("\nPaste the full redirect URL: ").strip()
code = parse_qs(urlparse(redirect_url).query)["code"][0]
response = httpx.post(
f"https://{STORE}/admin/oauth/access_token",
json={"client_id": CLIENT_ID, "client_secret": CLIENT_SECRET, "code": code},
)
data = response.json()
print("\n✅ Update your .env with this:")
print(f"SHOPIFY_ACCESS_TOKEN={data['access_token']}")