TikTok-Api icon indicating copy to clipboard operation
TikTok-Api copied to clipboard

[FEATURE_REQUEST] - Be able to log in an get the cookie.

Open elblogbruno opened this issue 4 years ago • 12 comments

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] Be able to log in an get the cookie.

Describe the solution you'd like A clear and concise description of what you want to happen. if we are able to log in an get the cookie I believe we can do thinks that are only able to do when we are log in, such as follow or give likes.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

By the moment I'll try getting the cookie manually from copying it from the devtools and try to find the follow endpoint and see how it goes.

Additional context Add any other context or screenshots about the feature request here.

I am doing a soon comercial app based on tiktok and I really need this kind of logged in capabilities.

elblogbruno avatar Aug 28 '20 20:08 elblogbruno

Issue-Label Bot is automatically applying the label feature_request to this issue, with a confidence of 0.95. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

issue-label-bot[bot] avatar Aug 28 '20 20:08 issue-label-bot[bot]

Hey @elblogbruno,

We did a quick check and this issue looks very darn similar to

  • #242 - Add Paging for hashtags
  • #237 - [BUG] - 'browser' object has no attribute 'verifyFp'
  • #235 - [BUG] - RuntimeError: This event loop is already running

This could be a coincidence, but if any of these issues solves your problem then I did a good job :smile:

If not, the maintainers will get to this issue shortly.

Cheers, Your Friendly Neighborhood ProBot

duplicate-issues[bot] avatar Aug 28 '20 20:08 duplicate-issues[bot]

I am doing a soon comercial app based on tiktok and I really need this kind of logged in capabilities.

You're building a "comercial" app based on an open-source free-to-use unofficial API? Don't you think the creator should get some money or at least a donation?

liamengland1 avatar Aug 28 '20 20:08 liamengland1

I am doing a soon comercial app based on tiktok and I really need this kind of logged in capabilities.

You're building a "comercial" app based on an open-source free-to-use unofficial API? Don't you think the creator should get some money or at least a donation?

By commercial I mean it will be used by people. If you know a way to contact tiktok so I can arrive to a commercial deal with them and get the project working the official way tell me, meanwhile I'll be using this one and decide in the future how I thank the creator for its work, by the moment thank you @davidteather !

elblogbruno avatar Aug 28 '20 20:08 elblogbruno

Yeah the TikTok captcha login seems pretty rough to get around using an api like this. If anyone else has any ideas on how to make the login process smoother that would be great.

A less ideal idea is to have the user log in by the self for each object and just capture that cookie, but more efficient than doing it by hand.

You’re welcome! You’re free to use the API for any reason you want commercial or otherwise without attribution or revenue to the project.

I’ve also started school so I’ll probably maintain any critical issues however new features will not be worked on as much as before. Unless I get covid and I put into quarantine and don’t have much else to do.

davidteather avatar Aug 29 '20 02:08 davidteather

Puppeteer is used to interact with the browser right? I feel I 've seen online videos where they create like Instagram or tinder bots. Maybe we can make the process of writing and clicking the buttons then extract the cookie. Tell me if I am wrong! Also, good luck at college!

elblogbruno avatar Aug 29 '20 07:08 elblogbruno

Yeah that’s sort of what I’m planning to do but you can’t just click the buttons and log in because there’s the captcha whenever you try to log into TikTok so you’d have to do it manually or we need to try to find a way around the captchas

davidteather avatar Aug 29 '20 14:08 davidteather

I have been the whole day but I am having no luck as I get always a 'blocked' response. Do you see something wrong?

 def follow_user(self, username, proxy=None, language='en', region='US'):
        """
          Get insights (what TikTok Pro calls "analytics") for a video.
          Note: this method requires cookies to be set in order to work, as you need to be logged in.
        """
        # maxCount = 50
        # maxCursor = 0
        # realCount = 1
        # if self.cookies is None:
        #     raise 'This method requires cookies to be set in order to work'
        # api_url = "https://m.tiktok.com/api/item_list/?{}&count={}&id=1&type=5&secUid=&maxCursor={}&minCursor=0&sourceType=12&appId=1233&region={}&language={}".format(
        #         self.__add_new_params__() ,str(realCount), str(maxCursor), str(region), str(language))
        data = self.getUserObject(username, proxy=proxy)
        api_url = "https://m.tiktok.com/api/commit/follow/user/?{}&".format(self.__add_new_params_loggedin__())
        #b = browser(api_url, language=language, proxy=proxy)
        b = browser(api_url, proxy=proxy)
        api_url = api_url + self.__add_new_cookie_params_login__(data['id'],b)
        print(api_url)
        #print(api_url.split("m.tiktok.com"))
        #print(data)
        r = requests.post(api_url, headers={
                'authority': 'm.tiktok.com',
                "method": "POST",
                'path': api_url.split("m.tiktok.com")[1],
                'scheme': 'https',
                'accept': 'application/json, text/plain, */*',
                "accept-encoding": "gzip, deflate, br",
                'accept-language': 'en-US,en;q=0.9',
                "content-type": "application/x-www-form-urlencoded",
                "content-length":"0",
                "dnt":"1",
                "referrer": b.referrer,
                'sec-fetch-dest': 'empty',
                'sec-fetch-mode': 'cors',
                'sec-fetch-site': 'same-site',
                "user-agent": b.userAgent
            }
            , proxies=self.__format_proxy(proxy)
            , cookies = self.cookies)
        return r.text

 def __add_new_params_loggedin__(self):
        return "aid=1988&app_name=tiktok_web&device_platform=web_pc&referer={}&user_agent={}&cookie_enabled=true".format(self.__format_new_params__("https://www.tiktok.com/@martinosky0012?lang=es"),self.__format_new_params__(self.userAgent)) + \
            "&screen_width={}&screen_height={}&browser_language={}&browser_platform={}&browser_name={}&browser_version={}".format(self.width, self.height, self.browser_language, self.browser_platform, self.browser_name, self.__format_new_params__(self.userAgent)) + \
            "&browser_online=true&ac=4g&page_referer={}&timezone_name={}&priority_region=&appId=1233&appType=m&isAndroid=false&isMobile=false".format(self.__format_new_params__("https://www.tiktok.com/@martinosky0012?lang=es"),self.timezone_name) + \
            "&isIOS=false&OS=windows&did=" + \
            str(random.randint(10000, 999999999))

    def __add_new_cookie_params_login__(self,username,b):
        return "tt-web-region=EN&uid=6821597396356711430&device_id=6866082963651134981&type=1&user_id={}&from=19&channel_id=3&from_pre=0&app_language=en&current_region=EN&fromWeb=1&verifyFp={}&_signature={}".format(username,"verify_kefe9te5_E924qRdY_3gDq_4mHR_AtoG_YtS3ZdsJ6f3o","_02B4Z6wo00901WIPqrQAAIBA.DEehXLYVq1iDq4AAAfK68")

elblogbruno avatar Aug 29 '20 15:08 elblogbruno

Describe the bug

Trying to get video bytes from get_Video_By_DownloadURL method, when this error occurs. This issue doesn't happen all the time. This error only happens occasionally. It works the rest of the time.

The buggy code

Please insert the code that is throwing errors or is giving you weird unexpected results.

vid = api.get_Video_By_DownloadURL(tiktok['video']['downloadAddr'])

Expected behavior

The video gets returned in bytes and stored to the vid variable

Error Trace (if any)

Put the error trace below if there's any error thrown.

Traceback (most recent call last):
  File "tiktok.py", line 51, in <module>
    vid = api.get_Video_By_DownloadURL(tiktok['video']['downloadAddr'])
  File "/usr/local/lib/python3.7/site-packages/TikTokApi/tiktok.py", line 897, in get_Video_By_DownloadURL
    return self.getBytes(b, proxy=proxy)
  File "/usr/local/lib/python3.7/site-packages/TikTokApi/tiktok.py", line 112, in getBytes
    query = {'verifyFp': b.verifyFp, '_signature': b.signature}
AttributeError: 'browser' object has no attribute 'verifyFp'

Desktop (please complete the following information):

  • OS: MacOS
  • TikTokApi Version: 3.5.2

venkrishr avatar Sep 20 '20 23:09 venkrishr

Yeah that’s sort of what I’m planning to do but you can’t just click the buttons and log in because there’s the captcha whenever you try to log into TikTok so you’d have to do it manually or we need to try to find a way around the captchas

That should be easy here is some doc about that : https://2captcha.com/2captcha-api#solving_tiktok I'm trying to login using selenium but with no success , found smth here https://github.com/carcabot/tiktok-signature/issues/92 maybe you guys can help me.

biellukasz avatar Oct 11 '20 20:10 biellukasz

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jan 10 '21 04:01 stale[bot]

It's less efficient to have to manually interact with it, but could it work to log in by hand once to "open a session," and then you can query several things, or would you need to log in for every query?

freyja-bt avatar Dec 15 '21 17:12 freyja-bt

Will not be supporting login

davidteather avatar Aug 08 '23 22:08 davidteather