poe-api icon indicating copy to clipboard operation
poe-api copied to clipboard

Login using email and password credentials instead of cookie token

Open jamezun opened this issue 1 year ago • 8 comments

Hi, is it possible to login using email and password credentials instead of cookie token? I have two poe accounts, and when I log into another, the other cookie token will become invalid. In order to allow to use api, does that mean I should never delete the cookies after using it?

jamezun avatar Apr 09 '23 14:04 jamezun

Hello @jamezun. I don't know if it can help you, but a few days ago, I created a script that allowed to automate the whole connection system (with a randomly generated email address). I think you can easily modify it or use it as inspiration to use your own email address. However, the code is not really optimized. Moreover I think that we could perhaps simplify it by passing via calls to the API.

Here is the script:

from TempMail import TempMail
import poe, time, re

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By

inbox   = TempMail.generateInbox()

options = webdriver.ChromeOptions()
options.add_argument("--headless")
options.add_experimental_option('excludeSwitches', ['enable-logging'])

driver  = webdriver.Chrome(options = options)

driver.get("https://poe.com/login")
assert "Poe" in driver.title

driver.find_element(By.CLASS_NAME, "MainSignupLoginSection_switchLoginMethodButton__B8mtS").click()

print("Email:", inbox.address)
email_input = driver.find_element(By.CLASS_NAME, "EmailInput_emailInput__4v_bn")
email_input.send_keys(inbox.address)
email_input.send_keys(Keys.RETURN)

code = None
while not code:
    print("Waiting for verification code...")

    for mail in TempMail.getEmails(inbox):
        if mail.subject != "Your verification code":
            continue
        
        code = ''.join([char for char in re.sub(re.compile("<style[^>]*>[^<]*<\/style>|<[^>]*>"), "", mail.html) if char.isdigit()])[2:8]

    time.sleep(30)

print("Verification code:", code)
code_input = driver.find_element(By.CLASS_NAME, "VerificationCodeInput_verificationCodeInput__YD3KV")
code_input.send_keys(code)
code_input.send_keys(Keys.RETURN)

token = driver.get_cookie("p-b")["value"]
print("Token:", token)

client = poe.Client(token)
print("Bots available: ", client.get_bot_names())

time.sleep(5)
driver.close()

Result after running the program.

Yarkis01 avatar Apr 10 '23 20:04 Yarkis01

Check this library that I have made : https://github.com/krishna2206/poe-auth

krishna2206 avatar Apr 12 '23 03:04 krishna2206

I could add OTP authentication into the library, but I'd leave actually reading the received emails up to the user. This'll probably make it into a future 0.3.x release.

ading2210 avatar Apr 15 '23 03:04 ading2210

Hello @jamezun. I don't know if it can help you, but a few days ago, I created a script that allowed to automate the whole connection system (with a randomly generated email address). I think you can easily modify it or use it as inspiration to use your own email address. However, the code is not really optimized. Moreover I think that we could perhaps simplify it by passing via calls to the API.

Here is the script:

from TempMail import TempMail
import poe, time, re

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By

inbox   = TempMail.generateInbox()

options = webdriver.ChromeOptions()
options.add_argument("--headless")
options.add_experimental_option('excludeSwitches', ['enable-logging'])

driver  = webdriver.Chrome(options = options)

driver.get("https://poe.com/login")
assert "Poe" in driver.title

driver.find_element(By.CLASS_NAME, "MainSignupLoginSection_switchLoginMethodButton__B8mtS").click()

print("Email:", inbox.address)
email_input = driver.find_element(By.CLASS_NAME, "EmailInput_emailInput__4v_bn")
email_input.send_keys(inbox.address)
email_input.send_keys(Keys.RETURN)

code = None
while not code:
    print("Waiting for verification code...")

    for mail in TempMail.getEmails(inbox):
        if mail.subject != "Your verification code":
            continue
        
        code = ''.join([char for char in re.sub(re.compile("<style[^>]*>[^<]*<\/style>|<[^>]*>"), "", mail.html) if char.isdigit()])[2:8]

    time.sleep(30)

print("Verification code:", code)
code_input = driver.find_element(By.CLASS_NAME, "VerificationCodeInput_verificationCodeInput__YD3KV")
code_input.send_keys(code)
code_input.send_keys(Keys.RETURN)

token = driver.get_cookie("p-b")["value"]
print("Token:", token)

client = poe.Client(token)
print("Bots available: ", client.get_bot_names())

time.sleep(5)
driver.close()

Result after running the program.

lol they banned the domains from tempmail-lol :rofl: are the devs for real :rofl: they left a 30-minute window where I could still use options.add_argument('--disable-blink-features=AutomationControlled') and then they legit banned all the cookies created from these temp mails :rofl: holy shit

xoiga123 avatar Apr 17 '23 18:04 xoiga123

Use email on deck it works till now

haruki-py avatar Jun 03 '23 06:06 haruki-py

Use email on deck it works till now

can you explain more please ?

TheLime1 avatar Jun 03 '23 10:06 TheLime1

Use email on deck it works till now

can you explain more please ?

You can use email on deck temporary mail. It worked on my first try after getting baneed on another temporary mail

haruki-py avatar Jun 03 '23 11:06 haruki-py

hi, why is it always stuck in the registration page when I enter my email to register poe?

CiaranYoung avatar Jun 30 '23 10:06 CiaranYoung