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

Could not authenticate to linkedin #39

Open
astronautjez07 opened this issue Aug 11, 2024 · 1 comment
Open

Could not authenticate to linkedin #39

astronautjez07 opened this issue Aug 11, 2024 · 1 comment

Comments

@astronautjez07
Copy link

[Fatal] Could not authenticate to linkedin. Set credentials in your environment variables

@syedbilalalam1
Copy link

syedbilalalam1 commented Oct 31, 2024

I think it's an issue with the new Linkedin authentication system. I've edited the code a bit and it works for me now.

Change the authentication function to this:

 # Authentication Fix
 def authenticate():
      print("[Info] Initiating LinkedIn authentication...")

# Use credentials from config file instead of environment variables
username = config.linkedin['username']
password = config.linkedin['password']

if not username or not password:
    raise ValueError("LinkedIn username and password must be set in config.py")

url = "https://www.linkedin.com/checkpoint/lg/login-submit"
csrf = "00000000-8a9a-474e-8bc1-6f10272b5fe6"
postdata = {
    'session_key': username,
    'session_password': password,
    'loginCsrfParam': csrf,
}
cookies = {'bcookie': 'v=2&%s' % csrf}

# Login Request
r = requests.post(url, postdata, cookies=cookies, allow_redirects=False)

try:
    session = r.cookies.get('li_at')
    if session:
        print(f"[Info] Obtained new session: {session[:25]}...")
        return {'li_at': session}
    else:
        raise RuntimeError("[Fatal] Could not authenticate to LinkedIn.")
except Exception as e:
    raise RuntimeError(f"[Fatal] Authentication failed: {e}")

Then you can replace the config with your email and password. It should work then! :)

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

No branches or pull requests

2 participants