|
1 | 1 | # SPDX-FileCopyrightText: 2021 Brent Rubell, written for Adafruit Industries |
2 | 2 | # |
3 | 3 | # SPDX-License-Identifier: Unlicense |
| 4 | + |
| 5 | +import os |
| 6 | + |
4 | 7 | from adafruit_display_text.label import Label |
5 | 8 | from adafruit_bitmap_font import bitmap_font |
6 | 9 | from adafruit_oauth2 import OAuth2 |
7 | 10 | from adafruit_pyportal import Network, Graphics |
8 | 11 |
|
9 | | -# Add a secrets.py to your filesystem that has a dictionary called secrets with "ssid" and |
10 | | -# "password" keys with your WiFi credentials. DO NOT share that file or commit it into Git or other |
11 | | -# source control. |
12 | | -# pylint: disable=no-name-in-module,wrong-import-order |
13 | | -try: |
14 | | - from secrets import secrets |
15 | | -except ImportError: |
16 | | - print("WiFi secrets are kept in secrets.py, please add them there!") |
17 | | - raise |
18 | | - |
19 | 12 | network = Network() |
20 | 13 | network.connect() |
21 | 14 |
|
|
50 | 43 | # Initialize an oauth2 object |
51 | 44 | google_auth = OAuth2( |
52 | 45 | network.requests, |
53 | | - secrets["google_client_id"], |
54 | | - secrets["google_client_secret"], |
| 46 | + os.getenv("GOOGLE_CLIENT_ID"), |
| 47 | + os.getenv("GOOGLE_CLIENT_SECRET"), |
55 | 48 | scopes, |
56 | 49 | ) |
57 | 50 |
|
|
87 | 80 |
|
88 | 81 | print("Successfully Authenticated with Google!") |
89 | 82 |
|
90 | | -# print formatted keys for adding to secrets.py |
91 | | -print("Add the following lines to your secrets.py file:") |
92 | | -print("\t'google_access_token' " + ":" + " '%s'," % google_auth.access_token) |
93 | | -print("\t'google_refresh_token' " + ":" + " '%s'" % google_auth.refresh_token) |
| 83 | +# print formatted keys for adding to settings.toml |
| 84 | +print("Add the following lines to your settings.toml file:") |
| 85 | +print(f'GOOGLE_ACCESS_TOKEN = "{google_auth.access_token}"') |
| 86 | +print(f'GOOGLE_REFRESH_TOKEN = "{google_auth.refresh_token}"') |
94 | 87 | # Remove QR code and code/verification labels |
95 | 88 | graphics.splash.pop() |
96 | 89 | graphics.splash.pop() |
97 | 90 | graphics.splash.pop() |
98 | 91 |
|
99 | 92 | label_overview_text.text = "Successfully Authenticated!" |
100 | 93 | label_verification_url.text = ( |
101 | | - "Check the REPL for tokens to add\n\tto your secrets.py file" |
| 94 | + "Check the REPL for tokens to add\n\tto your settings.toml file" |
102 | 95 | ) |
103 | 96 |
|
104 | 97 | # prevent exit |
|
0 commit comments