Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update login function to allow the use of a browser cookie to aid in logging in #126

Merged
merged 1 commit into from
Aug 14, 2023

Conversation

mnasra
Copy link
Contributor

@mnasra mnasra commented Jul 12, 2023

This also adds better error messaging when getting a 403 from the FPL API.

I've found logging in with this package no longer works, the workaround is to pull your own browser cookie and inject it into the response headers. This PR includes the ability to grab a cookie from the FPL_COOKIE environment variables and add it to the headers if specified.

I've found this allows the login + associated functions to work properly

…logging in. Also add better error messaging when getting a 403 from the FPL API.
@amosbastian
Copy link
Owner

I'll merge this when I wake up tomorrow morning and create a new release, thanks!

@amosbastian amosbastian merged commit 66c2039 into amosbastian:master Aug 14, 2023
1 check failed
@amosbastian amosbastian mentioned this pull request Aug 16, 2023
@razinc
Copy link

razinc commented Oct 9, 2023

Hi @mnasra, may I know how do you define the cookies? This is my code:

import asyncio

import aiohttp
import fpl_credentials
from fpl import FPL


async def main():
    async with aiohttp.ClientSession() as session:
        fpl = FPL(session)
        await fpl.login(
            email=fpl_credentials.EMAIL,
            password=fpl_credentials.PASSWORD,
            cookie={
                "pl_profile": "fpl_credentials.PL_PROFILE",
                "datadome": "fpl_credentials.DATADOME",
            },
        )
        league = await fpl.get_classic_league(314)


asyncio.run(main())

I got this error:
TypeError: Cannot serialize non-str key

I need to use this to make it works.

@mnasra
Copy link
Contributor Author

mnasra commented Oct 9, 2023

I logged into the FPL website and used a Chrome extension to extract my cookie which was a a long string and then set this to FPL_COOKIE within my environment variables.

I don't think setting it to a dictionary would work it has to be a string in the way I wrote it

@razinc
Copy link

razinc commented Oct 9, 2023

I also get the cookies from Chrome. Can you please share me how you set the FPL_COOKIE? An example of your used command might be helpful.

@mnasra
Copy link
Contributor Author

mnasra commented Oct 9, 2023

In windows I search "Edit the system environment variables" and put it in "environment variables". Variables = FPL_COOKIE and value = what I extracted from chrome

@razinc
Copy link

razinc commented Nov 18, 2023

Hi @amosbastian, I noticed the documentation is outdated. I guess this is because the docs is failing (based on the readme). I wish to contribute. Is there any log I can refer to?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants