diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 33c2a61..88bca9f 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -8,6 +8,9 @@ # Required version: 2 +sphinx: + configuration: docs/conf.py + build: os: ubuntu-20.04 tools: diff --git a/docs/conf.py b/docs/conf.py index 745db70..48c80a9 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -113,7 +113,6 @@ import sphinx_rtd_theme html_theme = "sphinx_rtd_theme" -html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."] # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, diff --git a/examples/oauth2_simpletest.py b/examples/oauth2_simpletest.py index c1c6881..878b83e 100644 --- a/examples/oauth2_simpletest.py +++ b/examples/oauth2_simpletest.py @@ -1,25 +1,23 @@ # SPDX-FileCopyrightText: 2020 Brent Rubell, written for Adafruit Industries # # SPDX-License-Identifier: Unlicense + +from os import getenv import ssl import wifi import socketpool import adafruit_requests from adafruit_oauth2 import OAuth2 -# Add a secrets.py to your filesystem that has a dictionary called secrets with "ssid" and -# "password" keys with your WiFi credentials. DO NOT share that file or commit it into Git or other -# source control. -# pylint: disable=no-name-in-module,wrong-import-order -try: - from secrets import secrets -except ImportError: - print("Credentials and tokens are kept in secrets.py, please add them there!") - raise +# Get WiFi details and Google keys, ensure these are setup in settings.toml +ssid = getenv("CIRCUITPY_WIFI_SSID") +password = getenv("CIRCUITPY_WIFI_PASSWORD") +google_client_id = getenv("google_client_id") +google_client_secret = getenv("google_client_secret") -print("Connecting to %s" % secrets["ssid"]) -wifi.radio.connect(secrets["ssid"], secrets["password"]) -print("Connected to %s!" % secrets["ssid"]) +print(f"Connecting to {ssid}") +wifi.radio.connect(ssid, password) +print(f"Connected to {ssid}") pool = socketpool.SocketPool(wifi.radio) requests = adafruit_requests.Session(pool, ssl.create_default_context()) @@ -29,9 +27,7 @@ scopes = ["email"] # Initialize an OAuth2 object -google_auth = OAuth2( - requests, secrets["google_client_id"], secrets["google_client_secret"], scopes -) +google_auth = OAuth2(requests, google_client_id, google_client_secret, scopes) # Request device and user codes # https://developers.google.com/identity/protocols/oauth2/limited-input-device#step-1:-request-device-and-user-codes diff --git a/examples/oauth2_simpletest_cpython.py b/examples/oauth2_simpletest_cpython.py index cd3a43b..3fa8025 100644 --- a/examples/oauth2_simpletest_cpython.py +++ b/examples/oauth2_simpletest_cpython.py @@ -1,20 +1,16 @@ # SPDX-FileCopyrightText: 2020 Brent Rubell, written for Adafruit Industries # # SPDX-License-Identifier: Unlicense + +from os import getenv import socket import ssl import adafruit_requests from adafruit_oauth2 import OAuth2 -# Add a secrets.py to your filesystem that has a dictionary called secrets with Google -# application tokens. DO NOT share that file or commit it into Git or other -# source control. -# pylint: disable=no-name-in-module,wrong-import-order -try: - from secrets import secrets -except ImportError: - print("Credentials and tokens are kept in secrets.py, please add them there!") - raise +# Get Google keys, ensure these are setup in settings.toml +google_client_id = getenv("google_client_id") +google_client_secret = getenv("google_client_secret") requests = adafruit_requests.Session(socket, ssl.create_default_context()) @@ -22,9 +18,7 @@ scopes = ["email"] # Initialize an OAuth2 object -google_auth = OAuth2( - requests, secrets["google_client_id"], secrets["google_client_secret"], scopes -) +google_auth = OAuth2(requests, google_client_id, google_client_secret, scopes) # Request device and user codes # https://developers.google.com/identity/protocols/oauth2/limited-input-device#step-1:-request-device-and-user-codes diff --git a/examples/oauth2_simpletest_esp32spi.py b/examples/oauth2_simpletest_esp32spi.py index 1172d5f..1428acc 100644 --- a/examples/oauth2_simpletest_esp32spi.py +++ b/examples/oauth2_simpletest_esp32spi.py @@ -1,6 +1,8 @@ # SPDX-FileCopyrightText: 2020 Brent Rubell, written for Adafruit Industries # # SPDX-License-Identifier: Unlicense + +from os import getenv import board import busio from digitalio import DigitalInOut @@ -10,15 +12,11 @@ import adafruit_requests from adafruit_oauth2 import OAuth2 -# Add a secrets.py to your filesystem that has a dictionary called secrets with "ssid" and -# "password" keys with your WiFi credentials. DO NOT share that file or commit it into Git or other -# source control. -# pylint: disable=no-name-in-module,wrong-import-order -try: - from secrets import secrets -except ImportError: - print("Credentials and tokens are kept in secrets.py, please add them there!") - raise +# Get WiFi details and Google keys, ensure these are setup in settings.toml +ssid = getenv("CIRCUITPY_WIFI_SSID") +password = getenv("CIRCUITPY_WIFI_PASSWORD") +google_client_id = getenv("google_client_id") +google_client_secret = getenv("google_client_secret") esp32_cs = DigitalInOut(board.ESP_CS) esp32_ready = DigitalInOut(board.ESP_BUSY) @@ -30,7 +28,7 @@ print("Connecting to AP...") while not esp.is_connected: try: - esp.connect_AP(secrets["ssid"], secrets["password"]) + esp.connect_AP(ssid, password) except RuntimeError as e: print("could not connect to AP, retrying: ", e) continue @@ -45,9 +43,7 @@ scopes = ["email"] # Initialize an OAuth2 object -google_auth = OAuth2( - requests, secrets["google_client_id"], secrets["google_client_secret"], scopes -) +google_auth = OAuth2(requests, google_client_id, google_client_secret, scopes) # Request device and user codes # https://developers.google.com/identity/protocols/oauth2/limited-input-device#step-1:-request-device-and-user-codes