Open spiros26 opened 1 year ago
Same here, it says state = response.url.query["state"] keyerror
/site-packages/fpl/fpl.py) in login(self, email, password) 589 ssl=ssl_context, 590 headers={"User-Agent": "Dalvik/2.1.0 (Linux; U; Android 5.1; PRO 5 Build/LMY47D)"}) as response: --> 591 state = response.url.query["state"] 592 if state == "fail":
Same, seems like its an auth issue. API requires a Cookie now.
@spiros26 @ivarbratberg,
Its an auth issue, I am still not sure how to retrieve the pl_profile
and datadome
, will look through their API to see if theres a way. As a workaround you have to manually edit the code, provide the Cookie and recompile.
It seems like its a one-time thing, I have not had to refresh or get a new version of pl_profile
and datadome
.
pl_profile
and datadome
from the Session cookie, once you've logged into your PL account.
You can access the cookies if you log on in chrome and then right click and select inspect > Application > CookiesUse the code snippet in fpl.py
file.
custom_cookie = {
'pl_profile': "",
'datadome': ""
}
headers = {
"User-Agent": "Dalvik/2.1.0 (Linux; U; Android 5.1; PRO 5 Build/LMY47D)"
}
async with self.session.post(login_url, data=payload,
ssl=ssl_context,
cookies=custom_cookie,
headers=headers) as response:
if 'state' not in response.url.query:
raise ValueError(f"Unsuccessful login: {response.status_code}")
state = response.url.query["state"]
if state == "fail":
reason = response.url.query["reason"]
raise ValueError(f"Login not successful, reason: {reason}")
I released a new version a few days ago that included #126
This PR includes the ability to grab a cookie from the FPL_COOKIE environment variables and add it to the headers if specified
So maybe you can try that out?
I'm having a very hard time figuring out how to put a cookie into an environment variable. Do I format it as json?
I tried to set the variables like this in fply.py, but I got a 403. I ensured code change was active and latest package.
cookie = '{ "pl_profile": "eyJzIjogIld6SXNOa....=", "datadome": "1UF....."}'
if not cookie:
raise Exception('No coolies provided')
cookie = os.getenv('FPL_COOKIE')
headers = {
"User-Agent": "Dalvik/2.1.0 (Linux; U; Android 5.1; PRO 5
Build/LMY47D)",
On Fri, Aug 18, 2023 at 9:58 AM kernalkue @.***> wrote:
I'm having a very hard time figuring out how to put a cookie into an environment variable. Do I format it as json?
— Reply to this email directly, view it on GitHub https://github.com/amosbastian/fpl/issues/127#issuecomment-1683519827, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADY74A2U4275J4D364KJQVDXV4OC3ANCNFSM6AAAAAA25PDQPY . You are receiving this because you were mentioned.Message ID: @.***>
Any hope for a solution here? I am unable to login using the pl_profile and data dome, seems like it's still unresolved, right?
The only solution is to use a selenium bot to login, but it's not effective because the fpl webapp uses datadome for bot detection.
Any hope for a solution here? I am unable to login using the pl_profile and data dome, seems like it's still unresolved, right?
@ThatPalAl Should work, please pass in the correct format for the cookie:
import asyncio
import aiohttp
from fpl import FPL
async def main():
async with aiohttp.ClientSession() as session:
fpl = FPL(session)
await fpl.login(
email="",
password="",
cookie = """datadome=;pl_profile="""
)
user = await fpl.get_user()
print(user)
asyncio.run(main())
@Tonio101 Not sure how to interpret that, so I need to replace just the 'datadome' with the value from my current session and same for the 'pl_profile'? I've put String values instead of those keywords but it's still the same 403 response. Should it look like this: cookie = """STRING_VALUE_OF_DATADTOME=;STRING_VALUE_OF_PL_PROFILE=""" or is that wrong?
You need to add the values of the cookies after the equals character. So would be:
cookie = """datadome=STRING_VALUE_OF_DATADTOME;pl_profile=STRING_VALUE_OF_PL_PROFILE"""
I can't get the login function to work. Maybe fpl has changed something and the headers don't work?