@@ -108,6 +108,7 @@ class PyPortal:
108108 """Class representing the Adafruit PyPortal.
109109
110110 :param url: The URL of your data source. Defaults to ``None``.
111+ :param headers: The headers for authentication, typically used by Azure API's.
111112 :param json_path: The list of json traversal to get data out of. Can be list of lists for
112113 multiple data points. Defaults to ``None`` to not use json.
113114 :param regexp_path: The list of regexp strings to get data out (use a single regexp group). Can
@@ -144,7 +145,7 @@ class PyPortal:
144145
145146 """
146147 # pylint: disable=too-many-instance-attributes, too-many-locals, too-many-branches, too-many-statements
147- def __init__ (self , * , url = None , json_path = None , regexp_path = None ,
148+ def __init__ (self , * , url = None , headers = None , json_path = None , regexp_path = None ,
148149 default_bg = 0x000000 , status_neopixel = None ,
149150 text_font = None , text_position = None , text_color = 0x808080 ,
150151 text_wrap = False , text_maxlen = 0 , text_transform = None ,
@@ -162,6 +163,7 @@ def __init__(self, *, url=None, json_path=None, regexp_path=None,
162163 self .set_backlight (1.0 ) # turn on backlight
163164
164165 self ._url = url
166+ self ._headers = headers
165167 if json_path :
166168 if isinstance (json_path [0 ], (list , tuple )):
167169 self ._json_path = json_path
@@ -666,7 +668,7 @@ def fetch(self):
666668 print ("Retrieving data..." , end = '' )
667669 self .neo_status ((100 , 100 , 0 )) # yellow = fetching data
668670 gc .collect ()
669- r = requests .get (self ._url )
671+ r = requests .get (self ._url , headers = self . _headers )
670672 gc .collect ()
671673 self .neo_status ((0 , 0 , 100 )) # green = got data
672674 print ("Reply is OK!" )
0 commit comments