#24 API Token Support

This commit is contained in:
David Zingg 2020-07-01 21:25:06 +02:00
parent b3e53821bb
commit 7d80c84393
2 changed files with 9 additions and 9 deletions

View File

@ -2,7 +2,6 @@
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="7e2e0eec-b22e-4d48-8f24-196d1ed9b51a" name="Default Changelist" comment=""> <list default="true" id="7e2e0eec-b22e-4d48-8f24-196d1ed9b51a" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/octoprint_mystromswitch/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/octoprint_mystromswitch/__init__.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/octoprint_mystromswitch/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/octoprint_mystromswitch/__init__.py" afterDir="false" />
</list> </list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@ -48,13 +47,6 @@
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1574193087583</updated> <updated>1574193087583</updated>
</task> </task>
<task id="LOCAL-00050" summary="#15 Beschreibung erstellen">
<created>1574876224274</created>
<option name="number" value="00050" />
<option name="presentableId" value="LOCAL-00050" />
<option name="project" value="LOCAL" />
<updated>1574876224274</updated>
</task>
<task id="LOCAL-00051" summary="#15 Beschreibung erstellen"> <task id="LOCAL-00051" summary="#15 Beschreibung erstellen">
<created>1574876349466</created> <created>1574876349466</created>
<option name="number" value="00051" /> <option name="number" value="00051" />
@ -391,7 +383,14 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1593630650365</updated> <updated>1593630650365</updated>
</task> </task>
<option name="localTasksCounter" value="99" /> <task id="LOCAL-00099" summary="#24 API Token Support">
<created>1593631193159</created>
<option name="number" value="00099" />
<option name="presentableId" value="LOCAL-00099" />
<option name="project" value="LOCAL" />
<updated>1593631193159</updated>
</task>
<option name="localTasksCounter" value="100" />
<servers /> <servers />
</component> </component>
<component name="UnknownFeatures"> <component name="UnknownFeatures">

View File

@ -180,6 +180,7 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
headers = {} headers = {}
if self.token is not None and self.token != "": if self.token is not None and self.token != "":
headers = {"Token": self.token} headers = {"Token": self.token}
self._logger.info(headers)
request = requests.get( request = requests.get(
'http://{}/report'.format(self.ip), headers=headers, timeout=1) 'http://{}/report'.format(self.ip), headers=headers, timeout=1)
if request.status_code == 200: if request.status_code == 200: