question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] - Response 403

See original GitHub issue

Since yesterday i have a problem with few endpoints. I’ve tested only getby endpoints and byHashtag and by Sound have responses 403

>>> api.byHashtag('love')

{'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36', 'accept-encoding': 'gzip, deflate, br', 'accept': 'application/json, text/plain, */*', 'Connection': 'keep-alive', 'authority': 'm.tiktok.com', 'method': 'GET', 'path': '/share/item/list?aid=1988&app_name=tiktok_web&device_platform=web&referer=&user_agent=Mozilla%2F5.0+(Windows+NT+10.0%3B+Win64%3B+x64)+AppleWebKit%2F537.36+(KHTML,+like+Gecko)+Chrome%2F84.0.4147.125+Safari%2F537.36&cookie_enabled=true&screen_width=2560&screen_height=1440&browser_language=&browser_platform=&browser_name=&browser_version=&browser_online=true&timezone_name=&priority_region=&appId=1233&appType=m&isAndroid=false&isMobile=false&isIOS=false&OS=windows&did=822148675&region=US&secUid=&id=4231&type=3&count=30&minCursor=0&maxCursor=0&shareUid=&recType=&lang=en&verifyFp=AaN99VturDQ2&_signature=_02B4Z6wo00f01SDv8tgAAIBB6rMaD8GoX..ZAABdw74', 'scheme': 'https', 'accept-language': 'en-US,en;q=0.9', 'referrer': 'https://www.tiktok.com/', 'sec-fetch-dest': 'empty', 'sec-fetch-mode': 'cors', 'sec-fetch-site': 'same-site'}
Converting response to JSON failed response is below (probably empty)
Traceback (most recent call last):
  File "~/PycharmProjects/backup_scrapers/vevn/lib/python3.8/site-packages/TikTokApi/tiktok.py", line 85, in getData
    return r.json()
  File "~/PycharmProjects/backup_scrapers/vevn/lib/python3.8/site-packages/requests/models.py", line 898, in json
    return complexjson.loads(self.text, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "~/PycharmProjects/backup_scrapers/vevn/lib/python3.8/site-packages/TikTokApi/tiktok.py", line 357, in byHashtag
    res = self.getData(api_url, b, proxy=proxy, language=language)
  File "~/PycharmProjects/backup_scrapers/vevn/lib/python3.8/site-packages/TikTokApi/tiktok.py", line 91, in getData
    raise Exception('Invalid Response')
Exception: Invalid Response

is this a bigger problem or something went wrong on my project?

Desktop:

  • OS: macOS Catalina
  • TikTokApi Version 3.4.3/3.4.6

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

7reactions
WinkyDevcommented, Sep 7, 2020

David, I’ve suggested a fix to the issue. apparently Tiktok decided to check the “Referer” header and it was written as “referrer” in the code. for everyone that need a quick fix like me, just change it on line 76 (tiktok.py)

1reaction
liamengland1commented, Sep 7, 2020

@Granitosaurus here is the URL of the calls from a guest window. Everything you said seems right. Also, it’s maxCursor, not max_cursor.

https://m.tiktok.com/share/item/list?aid=1988&app_name=tiktok_web&device_platform=web&referer=&user_agent=Mozilla%2F5.0+(Windows+NT+10.0%3B+Win64%3B+x64)+AppleWebKit%2F537.36+(KHTML,+like+Gecko)+Chrome%2F85.0.4183.83+Safari%2F537.36&cookie_enabled=true&screen_width=1920&screen_height=1080&browser_language=en-US&browser_platform=Win32&browser_name=Mozilla&browser_version=5.0+(Windows+NT+10.0%3B+Win64%3B+x64)+AppleWebKit%2F537.36+(KHTML,+like+Gecko)+Chrome%2F85.0.4183.83+Safari%2F537.36&browser_online=true&ac=4g&timezone_name=America%2FNew_York&priority_region=&appId=1233&region=US&appType=m&isAndroid=false&isMobile=false&isIOS=false&OS=windows&did=6869796811135485445&secUid=&id=229207&type=3&count=30&minCursor=0&maxCursor=0&shareUid=&recType=&lang=&verifyFp=verify_kessja7g_BCk1nsDe_YsYQ_4hyP_9bGX_fj1ypHrqLwx0&_signature=_02B4Z6wo00f01YYw7LgAAIBBwNHmb-qJuVWGMegAAD7ec2

Scrolling down: https://m.tiktok.com/share/item/list?aid=1988&app_name=tiktok_web&device_platform=web&referer=&user_agent=Mozilla%2F5.0+(Windows+NT+10.0%3B+Win64%3B+x64)+AppleWebKit%2F537.36+(KHTML,+like+Gecko)+Chrome%2F85.0.4183.83+Safari%2F537.36&cookie_enabled=true&screen_width=1920&screen_height=1080&browser_language=en-US&browser_platform=Win32&browser_name=Mozilla&browser_version=5.0+(Windows+NT+10.0%3B+Win64%3B+x64)+AppleWebKit%2F537.36+(KHTML,+like+Gecko)+Chrome%2F85.0.4183.83+Safari%2F537.36&browser_online=true&ac=4g&timezone_name=America%2FNew_York&priority_region=&appId=1233&region=US&appType=m&isAndroid=false&isMobile=false&isIOS=false&OS=windows&did=6869796811135485445&secUid=&id=229207&type=3&count=30&minCursor=0&maxCursor=30&shareUid=&recType=&lang=&verifyFp=verify_kessja7g_BCk1nsDe_YsYQ_4hyP_9bGX_fj1ypHrqLwx0&_signature=_02B4Z6wo00d015LyXQAAAIBD1BNX1sp3Sg-S81mAALv215

Read more comments on GitHub >

github_iconTop Results From Across the Web

What Is a 403 Forbidden Error (and How Can I Fix It)?
A 403 Forbidden Error occurs when you do not have permission to access a web page or something else on a web server....
Read more >
What Is the 403 Forbidden Error and How to Fix It (8 Methods ...
How to Fix the 403 Forbidden Error · 1. Check the .htaccess File · 2. Reset File and Directory Permissions · 3. Disable...
Read more >
403 Forbidden error: What it is and how to fix it - Allconnect.com
A 403 error is an HTTP status code that means “access denied.” If you ever had a treehouse as a kid, you may...
Read more >
What Does a 403 Forbidden Error Mean? How Do You Fix It?
The 403 Forbidden error is an HTTP status code that means that access to the page or resource you were trying to reach...
Read more >
403 Forbidden Error: What It Is and How to Fix It - Airbrake Blog
The 403 Forbidden Error is an HTTP response status code that indicates an identified client does not have proper authorization to access the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found