@@ 29-46 (lines=18) @@ | ||
26 | ||
27 | client = Client(API_HOST, False, key) |
|
28 | ||
29 | def fetch_token(facade): |
|
30 | if os.path.isfile(TOKEN_FILE + facade): |
|
31 | f = open(TOKEN_FILE + facade, 'r') |
|
32 | token = f.read() |
|
33 | f.close() |
|
34 | print("Reading " + facade + " token from disk.") |
|
35 | #global client |
|
36 | #client = Client(API_HOST, False, key, {facade: token}) |
|
37 | client.tokens[facade] = token |
|
38 | else: |
|
39 | pairingCode = client.create_token(facade) |
|
40 | print("Creating " + facade + " token.") |
|
41 | print("Please go to: %s/dashboard/merchant/api-tokens then enter \"%s\" then click the \"Find\" button, then click \"Approve\"" % (API_HOST, pairingCode)) |
|
42 | raw_input("When you've complete the above, hit enter to continue...") |
|
43 | print("token is: %s" % client.tokens[facade]) |
|
44 | f = open(TOKEN_FILE + facade, 'w') |
|
45 | f.write(client.tokens[facade]) |
|
46 | f.close() |
|
47 | ||
48 | def get_from_bitpay_api(client, uri, token): |
|
49 | payload = "?token=%s" % token |
@@ 30-45 (lines=16) @@ | ||
27 | ||
28 | client = Client(API_HOST, False, key) |
|
29 | ||
30 | def fetch_token(facade): |
|
31 | if os.path.isfile(TOKEN_FILE + facade): |
|
32 | f = open(TOKEN_FILE + facade, 'r') |
|
33 | token = f.read() |
|
34 | f.close() |
|
35 | print("Reading " + facade + " token from disk.") |
|
36 | client.tokens[facade] = token |
|
37 | else: |
|
38 | pairingCode = client.create_token(facade) |
|
39 | print("Creating " + facade + " token.") |
|
40 | print("Please go to: %s/dashboard/merchant/api-tokens then enter \"%s\" then click the \"Find\" button, then click \"Approve\"" % (API_HOST, pairingCode)) |
|
41 | raw_input("When you've complete the above, hit enter to continue...") |
|
42 | print("token is: %s" % client.tokens[facade]) |
|
43 | f = open(TOKEN_FILE + facade, 'w') |
|
44 | f.write(client.tokens[facade]) |
|
45 | f.close() |
|
46 | ||
47 | def get_from_bitpay_api(client, uri, token): |
|
48 | payload = "?token=%s" % token |