From 1953bc209ed53877da1d5470b9e329b5fbce0dab Mon Sep 17 00:00:00 2001 From: Gerhard Scheikl Date: Tue, 26 Nov 2024 15:20:46 +0100 Subject: [PATCH] Added option to specify an additional HTTP(s) header --- widget/resources/properties.xml | 10 ++++++++++ widget/source/hass/OAuthClient.mc | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/widget/resources/properties.xml b/widget/resources/properties.xml index 9d510c1..fd5f4d1 100644 --- a/widget/resources/properties.xml +++ b/widget/resources/properties.xml @@ -7,6 +7,8 @@ Garmin + + @@ -17,6 +19,8 @@ Group: (Group used for importing entities) Refresh on show (uses more battery and network) Entity ID to report battery level on startup (off if empty) + Additional HTTP(S) Header - Key + Additional HTTP(S) Header - Value @@ -41,5 +45,11 @@ + + + + + + \ No newline at end of file diff --git a/widget/source/hass/OAuthClient.mc b/widget/source/hass/OAuthClient.mc index 55f4b29..b8141f9 100644 --- a/widget/source/hass/OAuthClient.mc +++ b/widget/source/hass/OAuthClient.mc @@ -16,6 +16,8 @@ module Hass { hidden var _isLoggingIn; hidden var _isFetchingAccessToken; + hidden var _additionalHeaderKey; + hidden var _additionalHeaderValue; function initialize(options) { Comm.registerForOAuthMessages(method(:onReceiveCode)); @@ -28,6 +30,8 @@ module Hass { _tokenCallbacks = new [0]; _isLoggingIn = false; _isFetchingAccessToken = false; + _additionalHeaderKey = App.Properties.getValue("additional_header_key"); + _additionalHeaderValue = App.Properties.getValue("additional_header_value"); } function onSettingsChanged() { @@ -279,6 +283,10 @@ module Hass { } }; + if (_additionalHeaderKey.length() > 0) { + options[:headers][_additionalHeaderKey] = _additionalHeaderValue; + } + var passedOptions = context[:options]; if (passedOptions[:method] != null) {