Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_twitch_auth_tokens(fb_uname, fb_pword):
- driver = webdriver.PhantomJS()
- driver.get("https://www.twitch.tv/login")
- # log in via facebook
- driver.find_element_by_xpath("//button[@class='fb_button button']").click()
- driver.switch_to_window(driver.window_handles[1]) # switch to fb popup
- driver.find_element_by_xpath("//input[@id='email']").send_keys(fb_uname)
- driver.find_element_by_xpath("//input[@id='pass']").send_keys(fb_pword)
- driver.find_element_by_xpath("//input[@type='submit']").click()
- time.sleep(5) # gotta wait for this to properly log in
- driver.switch_to_window(driver.window_handles[0]) # switch back
- #
- driver.get("https://www.twitch.tv/kripparian")
- # save the cookies of interest
- twitch_persistent = ""
- twitch_api_token = ""
- cookies = driver.get_cookies()
- for cookie in cookies:
- if cookie['name'] == "persistent":
- twitch_persistent = cookie['value']
- if cookie['name'] == "api_token":
- twitch_api_token = cookie['value']
- driver.quit()
- return twitch_api_token, twitch_persistent
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement