From 625a07a832d98eba08180a3df8dee3b84da5e599 Mon Sep 17 00:00:00 2001 From: Rob Chandhok Date: Sat, 11 May 2019 01:11:02 -0700 Subject: [PATCH] Updated to include example of using a Bearer token (#9429) * Updated to include example of using a Bearer token This is the only way I got it to work with a secrets file and I thought it would be useful to share/capture the steps. * Minor changes --- source/_components/rest.markdown | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/source/_components/rest.markdown b/source/_components/rest.markdown index 1230e9a34f3..835a7b98218 100644 --- a/source/_components/rest.markdown +++ b/source/_components/rest.markdown @@ -191,6 +191,22 @@ Content-Type: application/json User-Agent: Home Assistant ``` +If you are accessing a resource protected by a `Bearer` token in an `Authorization` header, you can either put the token in the header field of the sensor configuration (not recommended) or store the token in your [`secrets.yaml`](/docs/configuration/secrets/) file. In that case, be sure to include the word `Bearer` in the `secrets` file. + +```yaml +sensor: + - platform: rest + resource: http://IP_ADDRESS:5000/sensor + headers: + Authorization: !secret my_sensor_secret_token +``` + +Example entry for the `secrets.yaml` file: + +```yaml +my_sensor_secret_token: Bearer gh_DHQIXKVf6Pr4H8Yqz8uhApk_mnV6Zje6Pr4H8Yqz8A8nCxz6SBghQdS51 +``` + ### {% linkable_title Use GitHub to get the latest release of Home Assistant %} This sample is very similar to the [`updater`](/components/updater/) component but the information is received from GitHub.