Update main.py
Browse files
main.py
CHANGED
|
@@ -20,7 +20,6 @@ async def tiktok_auth_callback(request: Request):
|
|
| 20 |
content={"message": "Missing 'code' parameter from TikTok OAuth."}
|
| 21 |
)
|
| 22 |
|
| 23 |
-
# Exchange code for tokens
|
| 24 |
token_url = "https://business-api.tiktok.com/open_api/v1.3/oauth2/access_token/"
|
| 25 |
payload = {
|
| 26 |
"app_id": CLIENT_KEY,
|
|
@@ -37,7 +36,14 @@ async def tiktok_auth_callback(request: Request):
|
|
| 37 |
content={"message": "Token exchange failed", "details": data}
|
| 38 |
)
|
| 39 |
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
return JSONResponse(
|
| 43 |
content={
|
|
|
|
| 20 |
content={"message": "Missing 'code' parameter from TikTok OAuth."}
|
| 21 |
)
|
| 22 |
|
|
|
|
| 23 |
token_url = "https://business-api.tiktok.com/open_api/v1.3/oauth2/access_token/"
|
| 24 |
payload = {
|
| 25 |
"app_id": CLIENT_KEY,
|
|
|
|
| 36 |
content={"message": "Token exchange failed", "details": data}
|
| 37 |
)
|
| 38 |
|
| 39 |
+
# ✅ These lines only run if token exchange succeeded
|
| 40 |
+
access_token = data["data"]["access_token"]
|
| 41 |
+
refresh_token = data["data"]["refresh_token"]
|
| 42 |
+
advertiser_ids = data["data"]["advertiser_ids"]
|
| 43 |
+
|
| 44 |
+
print("✅ Access Token:", access_token)
|
| 45 |
+
print("🔁 Refresh Token:", refresh_token)
|
| 46 |
+
print("📢 Advertiser IDs:", advertiser_ids)
|
| 47 |
|
| 48 |
return JSONResponse(
|
| 49 |
content={
|