import requests
import json


def lacrosse_login(email, password):
    """
    Login to the La Crosse weather data and return the euser's valid token

    :param email: User's login e-mail address
    :param password: Users'a login password
    """

    url = "https://www.googleapis.com/" \
          "identitytoolkit/v3/relyingparty/verifyPassword?" \
          "key=AIzaSyD-Uo0hkRIeDYJhyyIg-TvAv8HhExARIO4"
    payload = {
        "email": email,
        "returnSecureToken": True,
        "password": password
    }
    r = requests.post(url, data=json.dumps(payload))
    body = r.json()
    token = body.get('idToken')

    if token is None:
        raise ConnectionError("Login Failed. Check credentials and try again")
    return token