-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtgtg-credtentials.py
More file actions
24 lines (18 loc) · 828 Bytes
/
Copy pathtgtg-credtentials.py
File metadata and controls
24 lines (18 loc) · 828 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import json
import base64
import argparse
from tgtg import TgtgClient
# Parse arguments
parser = argparse.ArgumentParser(description='Get credentials from Too Good To Go.')
parser.add_argument('-e', '--email', type=str, required=True, help='Email address to use for login.')
args = parser.parse_args()
# Get credentials from Too Good To Go
client = TgtgClient(email=args.email)
credentials = client.get_credentials()
# Encode credentials to base64
encoded_credentials = base64.b64encode(json.dumps(credentials).encode("utf-8")).decode("utf-8")
# Print encoded credentials
print("Copy the following line and paste it in your .env file. Make sure to set the TGTG_CREDTENIALS variable.")
print("----------------------------------")
print("TGTG_CREDENTIALS=" + encoded_credentials)
print("----------------------------------")