Skip to content

Commit 6be74c8

Browse files
remove get_access_token
1 parent c64f473 commit 6be74c8

File tree

1 file changed

+6
-28
lines changed

1 file changed

+6
-28
lines changed

api/client/samples/crop_models/sugar.py

+6-28
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,18 @@
55
# Usage example:
66
#
77
# export PYTHONPATH=/your/path/to/gro
8-
# python sugar.py --user_email ...
9-
#
10-
# If you don't want to enter the password each time, print a token,
11-
# save it and use as follows:
8+
# python sugar.py --token ...
129
#
13-
# export GROAPI_TOKEN=`python sugar.py --user_email ... --print_token`
10+
# You can either save the gro api token in environment variable GROAPI_TOKEN and run
1411
# python sugar.py
12+
# OR use the token directly via command line argument:
13+
# python sugar.py --token YOUR_API_TOKEN_HERE
1514
#
16-
# Or if you don't save the token, you can pass it via cmd line
17-
#
18-
# python sugar.py --token ...
1915
#
2016
# Ref: https://app.gro-intelligence.com/#/displays/23713
2117

2218
import argparse
23-
import getpass
24-
import sys
2519
import unicodecsv
26-
import groclient.lib
2720
import os
2821
from api.client.crop_model import CropModel
2922

@@ -32,26 +25,11 @@
3225

3326
def main():
3427
parser = argparse.ArgumentParser(description="Gro api client")
35-
parser.add_argument("--user_email")
36-
parser.add_argument("--user_password")
37-
parser.add_argument("--print_token", action="store_true")
3828
parser.add_argument("--token", default=os.environ.get("GROAPI_TOKEN", None))
3929
args = parser.parse_args()
40-
assert args.user_email or args.token, "Need --token or --user_email"
41-
access_token = None
42-
if args.token:
43-
access_token = args.token
44-
else:
45-
if not args.user_password:
46-
args.user_password = getpass.getpass()
47-
access_token = groclient.lib.get_access_token(
48-
API_HOST, args.user_email, args.user_password
49-
)
50-
if args.print_token:
51-
print(access_token)
52-
sys.exit(0)
30+
assert args.token, "Need --token or the token set in GROAPI_TOKEN environment variable"
5331

54-
model = CropModel(API_HOST, access_token)
32+
model = CropModel(API_HOST, args.token)
5533
model.add_data_series(
5634
item="sugarcane", metric="production quantity", region="Brazil"
5735
)

0 commit comments

Comments
 (0)