Skip to content

Commit 9557764

Browse files
author
brentru
committed
warning for api key sharing
1 parent 227552a commit 9557764

9 files changed

+78
-34
lines changed

examples/aio_basics/adafruitio_00_publish.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,24 @@
66
77
Author(s): Brent Rubell, Todd Treece for Adafruit Industries
88
"""
9+
# Import standard python modules
910
import time
11+
1012
# Import Adafruit IO REST client.
1113
from Adafruit_IO import Client, Feed
1214

1315
# holds the count for the feed
1416
run_count = 0
1517

1618
# Set to your Adafruit IO key.
17-
ADAFRUIT_IO_USERNAME = 'YOUR_AIO_USERNAME'
19+
# Remember, your key is a secret,
20+
# so make sure not to publish it when you publish this code!
1821
ADAFRUIT_IO_KEY = 'YOUR_AIO_KEY'
1922

23+
# Set to your Adafruit IO username.
24+
# (go to https://accounts.adafruit.com to find your username)
25+
ADAFRUIT_IO_USERNAME = 'YOUR_AIO_USERNAME'
26+
2027
# Create an instance of the REST client.
2128
aio = Client(ADAFRUIT_IO_USERNAME, ADAFRUIT_IO_KEY)
2229

@@ -32,4 +39,3 @@
3239
# Adafruit IO is rate-limited for publishing
3340
# so we'll need a delay for calls to aio.send_data()
3441
time.sleep(3)
35-

examples/aio_basics/adafruitio_01_subscribe.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,27 @@
88
# Import standard python modules.
99
import sys
1010

11-
# This example uses the MQTTClient, instead of the REST client
11+
# This example uses the MQTTClient instead of the REST client
1212
from Adafruit_IO import MQTTClient
1313

14-
# Set to your Adafruit IO key & username below.
15-
ADAFRUIT_IO_USERNAME = 'YOUR_AIO_USERNAME'
14+
# Set to your Adafruit IO key.
15+
# Remember, your key is a secret,
16+
# so make sure not to publish it when you publish this code!
1617
ADAFRUIT_IO_KEY = 'YOUR_AIO_KEY'
1718

19+
# Set to your Adafruit IO username.
20+
# (go to https://accounts.adafruit.com to find your username)
21+
ADAFRUIT_IO_USERNAME = 'YOUR_AIO_USERNAME'
22+
1823
# Set to the ID of the feed to subscribe to for updates.
1924
FEED_ID = 'counter'
2025

2126
# Define callback functions which will be called when certain events happen.
2227
def connected(client):
23-
"""Connected function will be called when the client is connected to Adafruit IO.
24-
This is a good place to subscribe to feed changes. The client parameter
25-
passed to this function is the Adafruit IO MQTT client so you can make
26-
calls against it easily.
28+
"""Connected function will be called when the client is connected to
29+
Adafruit IO.This is a good place to subscribe to feed changes. The client
30+
parameter passed to this function is the Adafruit IO MQTT client so you
31+
can make calls against it easily.
2732
"""
2833
# Subscribe to changes on a feed named Counter.
2934
print('Subscribing to Feed {0}'.format(FEED_ID))

examples/aio_basics/adafruitio_04_location.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
"""
22
'adafruitio_04_location.py'
33
==================================
4-
Example of sending GPS data points
4+
Example of sending GPS data points
55
to an Adafruit IO Feed using the API
66
77
Author(s): Brent Rubell, Todd Treece
88
"""
9-
# Import python system libraries
9+
# Import standard python modules
1010
import time
11+
1112
# Import Adafruit IO REST client.
1213
from Adafruit_IO import Client, Feed, RequestError
1314

1415
# Set to your Adafruit IO key.
15-
ADAFRUIT_IO_USERNAME = 'YOUR_USERNAME'
16+
# Remember, your key is a secret,
17+
# so make sure not to publish it when you publish this code!
1618
ADAFRUIT_IO_KEY = 'YOUR_AIO_KEY'
1719

20+
# Set to your Adafruit IO username.
21+
# (go to https://accounts.adafruit.com to find your username)
22+
ADAFRUIT_IO_USERNAME = 'YOUR_AIO_USERNAME'
23+
1824
# Create an instance of the REST client.
1925
aio = Client(ADAFRUIT_IO_USERNAME, ADAFRUIT_IO_KEY)
2026

@@ -35,6 +41,7 @@
3541
lon = -74.005334
3642
ele = 6 # elevation above sea level (meters)
3743

44+
3845
while True:
3946
print('\nSending Values to location feed...\n')
4047
print('\tValue: ', value)
@@ -52,6 +59,7 @@
5259
# Read the location data back from IO
5360
print('\nData Received by Adafruit IO Feed:\n')
5461
data = aio.receive(location.key)
55-
print('\tValue: {0}\n\tLat: {1}\n\tLon: {2}\n\tEle: {3}'.format(data.value, data.lat, data.lon, data.ele))
62+
print('\tValue: {0}\n\tLat: {1}\n\tLon: {2}\n\tEle: {3}'
63+
.format(data.value, data.lat, data.lon, data.ele))
5664
# wait loop_delay seconds to avoid api throttle
57-
time.sleep(loop_delay)
65+
time.sleep(loop_delay)

examples/aio_basics/adafruitio_06_digital_in.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,25 @@
66
77
Author(s): Brent Rubell, Todd Treece
88
"""
9-
# import python system libraries
9+
# Import standard python modules
1010
import time
1111

1212
# import Adafruit Blinka
1313
from digitalio import DigitalInOut, Direction, Pull
14-
import digitalio
1514
import board
1615

1716
# import Adafruit IO REST client.
1817
from Adafruit_IO import Client, Feed, RequestError
1918

2019
# Set to your Adafruit IO key.
21-
ADAFRUIT_IO_USERNAME = 'YOUR_AIO_USERNAME'
20+
# Remember, your key is a secret,
21+
# so make sure not to publish it when you publish this code!
2222
ADAFRUIT_IO_KEY = 'YOUR_AIO_KEY'
2323

24+
# Set to your Adafruit IO username.
25+
# (go to https://accounts.adafruit.com to find your username)
26+
ADAFRUIT_IO_USERNAME = 'YOUR_AIO_USERNAME'
27+
2428
# Create an instance of the REST client.
2529
aio = Client(ADAFRUIT_IO_USERNAME, ADAFRUIT_IO_KEY)
2630

examples/aio_basics/adafruitio_07_digital_out.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,25 @@
66
77
Author(s): Brent Rubell, Todd Treece
88
"""
9-
# import python system libraries
9+
# Import standard python modules
1010
import time
1111

1212
# import Adafruit Blinka
1313
from digitalio import DigitalInOut, Direction
14-
import digitalio
1514
import board
1615

1716
# import Adafruit IO REST client.
1817
from Adafruit_IO import Client, Feed, RequestError
1918

2019
# Set to your Adafruit IO key.
21-
ADAFRUIT_IO_USERNAME = 'YOUR_AIO_USERNAME'
20+
# Remember, your key is a secret,
21+
# so make sure not to publish it when you publish this code!
2222
ADAFRUIT_IO_KEY = 'YOUR_AIO_KEY'
2323

24+
# Set to your Adafruit IO username.
25+
# (go to https://accounts.adafruit.com to find your username)
26+
ADAFRUIT_IO_USERNAME = 'YOUR_AIO_USERNAME'
27+
2428
# Create an instance of the REST client.
2529
aio = Client(ADAFRUIT_IO_USERNAME, ADAFRUIT_IO_KEY)
2630

@@ -34,6 +38,7 @@
3438
led = digitalio.DigitalInOut(board.D5)
3539
led.direction = Direction.OUTPUT
3640

41+
3742
while True:
3843
data = aio.receive(digital.key)
3944
if int(data.value) == 1:

examples/api/data.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@
77
import datetime
88

99
# Set to your Adafruit IO key.
10-
ADAFRUIT_IO_USERNAME = 'YOUR ADAFRUIT IO USERNAME'
11-
ADAFRUIT_IO_KEY = 'YOUR ADAFRUIT IO KEY'
10+
# Remember, your key is a secret,
11+
# so make sure not to publish it when you publish this code!
12+
ADAFRUIT_IO_KEY = 'YOUR_AIO_KEY'
13+
14+
# Set to your Adafruit IO username.
15+
# (go to https://accounts.adafruit.com to find your username)
16+
ADAFRUIT_IO_USERNAME = 'YOUR_AIO_USERNAME'
1217

1318
# Create an instance of the REST client.
1419
aio = Client(ADAFRUIT_IO_USERNAME, ADAFRUIT_IO_KEY)

examples/api/feeds.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@
77
import json
88

99
# Set to your Adafruit IO key.
10-
ADAFRUIT_IO_USERNAME = 'YOUR ADAFRUIT IO USERNAME'
11-
ADAFRUIT_IO_KEY = 'YOUR ADAFRUIT IO KEY'
10+
# Remember, your key is a secret,
11+
# so make sure not to publish it when you publish this code!
12+
ADAFRUIT_IO_KEY = 'YOUR_AIO_KEY'
13+
14+
# Set to your Adafruit IO username.
15+
# (go to https://accounts.adafruit.com to find your username)
16+
ADAFRUIT_IO_USERNAME = 'YOUR_AIO_USERNAME'
1217

1318
# Create an instance of the REST client.
1419
aio = Client(ADAFRUIT_IO_USERNAME, ADAFRUIT_IO_KEY)

examples/mqtt/mqtt_client.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@
99
# Import Adafruit IO MQTT client.
1010
from Adafruit_IO import MQTTClient
1111

12-
13-
# Set to your Adafruit IO key & username below.
14-
ADAFRUIT_IO_KEY = 'YOUR ADAFRUIT IO KEY'
15-
ADAFRUIT_IO_USERNAME = 'YOUR ADAFRUIT IO USERNAME' # See https://accounts.adafruit.com
16-
# to find your username.
12+
# Set to your Adafruit IO key.
13+
# Remember, your key is a secret,
14+
# so make sure not to publish it when you publish this code!
15+
ADAFRUIT_IO_KEY = 'YOUR_AIO_KEY'
16+
17+
# Set to your Adafruit IO username.
18+
# (go to https://accounts.adafruit.com to find your username)
19+
ADAFRUIT_IO_USERNAME = 'YOUR_AIO_USERNAME'
1720

1821

1922
# Define callback functions which will be called when certain events happen.

examples/mqtt/mqtt_subscribe.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@
88
# Import Adafruit IO MQTT client.
99
from Adafruit_IO import MQTTClient
1010

11-
12-
# Set to your Adafruit IO key & username below.
13-
ADAFRUIT_IO_KEY = 'YOUR ADAFRUIT IO KEY'
14-
ADAFRUIT_IO_USERNAME = 'YOUR ADAFRUIT IO USERNAME' # See https://accounts.adafruit.com
15-
# to find your username.
11+
# Set to your Adafruit IO key.
12+
# Remember, your key is a secret,
13+
# so make sure not to publish it when you publish this code!
14+
ADAFRUIT_IO_KEY = 'YOUR_AIO_KEY'
15+
16+
# Set to your Adafruit IO username.
17+
# (go to https://accounts.adafruit.com to find your username)
18+
ADAFRUIT_IO_USERNAME = 'YOUR_AIO_USERNAME'
1619

1720
# Set to the ID of the feed to subscribe to for updates.
1821
FEED_ID = 'DemoFeed'

0 commit comments

Comments
 (0)