Document 'force' in external_auth (#387)

This commit is contained in:
Paulus Schoutsen 2020-01-13 06:13:30 -08:00 committed by GitHub
parent 3c61ad3c81
commit 732ee0523b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,15 +12,19 @@ To activate this API, load the frontend with `?external_auth=1` appended to the
_This API has been introduced in Home Assistant 0.78._
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.
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.
The `force` boolean has been introduced in Home Assistant 0.104 and might not always be available.
```js
window.externalApp.getExternalAuth({
callback: 'externalAuthSetToken'
callback: "externalAuthSetToken",
force: true
});
// or
window.webkit.messageHandlers.getExternalAuth.postMessage({
callback: 'externalAuthSetToken'
callback: "externalAuthSetToken",
force: true
});
```
@ -29,8 +33,8 @@ The response should contain a boolean if it was successful and an object contain
```js
// To be called by external app
window.externalAuthSetToken(true, {
"access_token": "qwere",
"expires_in": 1800
access_token: "qwere",
expires_in: 1800
});
// If unable to get new access token
@ -47,11 +51,11 @@ When the user presses the logout button on the profile page, the external app wi
```js
window.externalApp.revokeExternalAuth({
callback: 'externalAuthRevokeToken'
callback: "externalAuthRevokeToken"
});
// or
window.webkit.messageHandlers.revokeExternalAuth.postMessage({
callback: 'externalAuthRevokeToken'
callback: "externalAuthRevokeToken"
});
```