Skip to content

Instantly share code, notes, and snippets.

@asilbalaban
Created January 16, 2023 17:07
Show Gist options
  • Save asilbalaban/a750cf7af1fa757b4bae7b870db0f6c4 to your computer and use it in GitHub Desktop.
Save asilbalaban/a750cf7af1fa757b4bae7b870db0f6c4 to your computer and use it in GitHub Desktop.

Revisions

  1. asilbalaban revised this gist Jan 16, 2023. 1 changed file with 0 additions and 10 deletions.
    10 changes: 0 additions & 10 deletions sorare-login.py
    Original file line number Diff line number Diff line change
    @@ -11,16 +11,6 @@ def getSalt(email):
    return response.json()["salt"]

    def login(hashedPassword, email, aud):
    """
    curl 'https://api.sorare.com/graphql' \
    -H 'content-type: application/json' \
    -d '{
    "operationName": "SignInMutation",
    "variables": { "input": { "email": "<YourEmail>", "password": "<YourHashPassword>" } },
    "query": "mutation SignInMutation($input: signInInput!) { signIn(input: $input) { currentUser { slug jwtToken(aud: \"<YourAud>\") { token expiredAt } } errors { message } } }"
    }'
    """

    headers = {
    'content-type': 'application/json',
    }
  2. asilbalaban created this gist Jan 16, 2023.
    49 changes: 49 additions & 0 deletions sorare-login.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,49 @@
    import requests
    import bcrypt

    """
    pip3 install bcrypt
    """

    def getSalt(email):
    url = "https://api.sorare.com/api/v1/users/" + email
    response = requests.get(url)
    return response.json()["salt"]

    def login(hashedPassword, email, aud):
    """
    curl 'https://api.sorare.com/graphql' \
    -H 'content-type: application/json' \
    -d '{
    "operationName": "SignInMutation",
    "variables": { "input": { "email": "<YourEmail>", "password": "<YourHashPassword>" } },
    "query": "mutation SignInMutation($input: signInInput!) { signIn(input: $input) { currentUser { slug jwtToken(aud: \"<YourAud>\") { token expiredAt } } errors { message } } }"
    }'
    """

    headers = {
    'content-type': 'application/json',
    }

    json_data = {
    'operationName': 'SignInMutation',
    'variables': {
    'input': {
    'email': email,
    'password': hashedPassword.decode('utf-8'),
    },
    },
    'query': 'mutation SignInMutation($input: signInInput!) { signIn(input: $input) { currentUser { slug jwtToken(aud: "'+aud+'") { token expiredAt } } errors { message } } }',
    }

    response = requests.post('https://api.sorare.com/graphql', headers=headers, json=json_data)
    return response.json()

    if __name__ == "__main__":
    aud = "<your-aud>"
    email = "<your-email>"
    password = "<your-password>".encode('utf-8')
    salt = getSalt(email).encode('utf-8')
    hashedPassword = bcrypt.hashpw(password, salt)
    response = login(hashedPassword, email, aud)
    print(response)