Skip to content

Commit 6686a6c

Browse files
authored
PyPortal_Google_Calendar: update to settings.toml
1 parent 76cd05b commit 6686a6c

1 file changed

Lines changed: 10 additions & 17 deletions

File tree

  • PyPortal/PyPortal_Google_Calendar/authenticator

PyPortal/PyPortal_Google_Calendar/authenticator/code.py

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,14 @@
11
# SPDX-FileCopyrightText: 2021 Brent Rubell, written for Adafruit Industries
22
#
33
# SPDX-License-Identifier: Unlicense
4+
5+
import os
6+
47
from adafruit_display_text.label import Label
58
from adafruit_bitmap_font import bitmap_font
69
from adafruit_oauth2 import OAuth2
710
from adafruit_pyportal import Network, Graphics
811

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-
1912
network = Network()
2013
network.connect()
2114

@@ -50,8 +43,8 @@
5043
# Initialize an oauth2 object
5144
google_auth = OAuth2(
5245
network.requests,
53-
secrets["google_client_id"],
54-
secrets["google_client_secret"],
46+
os.getenv("GOOGLE_CLIENT_ID"),
47+
os.getenv("GOOGLE_CLIENT_SECRET"),
5548
scopes,
5649
)
5750

@@ -87,18 +80,18 @@
8780

8881
print("Successfully Authenticated with Google!")
8982

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}"')
9487
# Remove QR code and code/verification labels
9588
graphics.splash.pop()
9689
graphics.splash.pop()
9790
graphics.splash.pop()
9891

9992
label_overview_text.text = "Successfully Authenticated!"
10093
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"
10295
)
10396

10497
# prevent exit

0 commit comments

Comments
 (0)