You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/frontend/external-authentication.md
+37-16Lines changed: 37 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,25 +6,36 @@ By default, the frontend will take care of its own authentication tokens. If non
6
6
7
7
If you want to embed the Home Assistant frontend in an external app, you will want to store the authentication inside the app but make it available to the frontend. To support this, Home Assistant exposes an external authentication API.
8
8
9
-
To activate this API, load the frontend with `?external_auth=1` appended to the URL. If this is passed in, Home Assistant will expect either `window.externalApp` (for Android) or `window.webkit.messageHandlers` (for iOS) to be defined containing the methods described below.
9
+
To activate this API, load the frontend with `?external_auth=1` appended to the URL. If this is passed in, Home Assistant will expect either `window.externalAppV2` (Android V2, recommended), `window.externalApp` (Android V1, fallback) or `window.webkit.messageHandlers` (iOS) to be defined containing the methods described below.
10
10
11
-
## Get access token
11
+
:::note
12
+
V2 (`window.externalAppV2`) is only available when the WebView supports [`WebViewFeature.WEB_MESSAGE_LISTENER`][web-message-listener]. The app should fall back to V1 otherwise.
13
+
:::
12
14
13
-
_This API has been introduced in Home Assistant 0.78._
15
+
## Get access token
14
16
15
17
When the frontend loads, it will request an access token from the external authentication. It does so by calling one of the following methods with an options object. The options object defines the callback method to be called with the response and an optional `force` boolean which is set to `true` if the access token should be refreshed, regardless if it has expired or not.
16
18
17
19
The `force` boolean has been introduced in Home Assistant 0.104 and might not always be available.
@@ -45,17 +56,25 @@ The frontend will call this method when the page first loads and whenever it nee
45
56
46
57
## Revoke token
47
58
48
-
_This API has been introduced in Home Assistant 0.78._
49
-
50
59
When the user presses the logout button on the profile page, the external app will have to [revoke the refresh token](auth_api.md#revoking-a-refresh-token), and log the user out.
0 commit comments