diff --git a/src/auth/ha-auth-flow.js b/src/auth/ha-auth-flow.js index 70d3652700..e2770eee22 100644 --- a/src/auth/ha-auth-flow.js +++ b/src/auth/ha-auth-flow.js @@ -35,7 +35,6 @@ class HaAuthFlow extends EventsMixin(PolymerElement) { return { authProvider: Object, clientId: String, - clientSecret: String, redirectUri: String, oauth2State: String, _state: { @@ -54,10 +53,8 @@ class HaAuthFlow extends EventsMixin(PolymerElement) { fetch('/auth/login_flow', { method: 'POST', - headers: { - Authorization: `Basic ${btoa(`${this.clientId}:${this.clientSecret}`)}` - }, body: JSON.stringify({ + client_id: this.clientId, handler: [this.authProvider.type, this.authProvider.id], redirect_uri: this.redirectUri, }) @@ -89,12 +86,13 @@ class HaAuthFlow extends EventsMixin(PolymerElement) { } this._state = 'loading'; + const postData = Object.assign({}, this._stepData, { + client_id: this.clientId, + }); + fetch(`/auth/login_flow/${this._step.flow_id}`, { method: 'POST', - headers: { - Authorization: `Basic ${btoa(`${this.clientId}:${this.clientSecret}`)}` - }, - body: JSON.stringify(this._stepData) + body: JSON.stringify(postData) }).then((response) => { if (!response.ok) throw new Error(); return response.json(); diff --git a/src/auth/ha-pick-auth-provider.js b/src/auth/ha-pick-auth-provider.js index 7be58e73c8..41001ac776 100644 --- a/src/auth/ha-pick-auth-provider.js +++ b/src/auth/ha-pick-auth-provider.js @@ -45,17 +45,12 @@ class HaPickAuthProvider extends EventsMixin(PolymerElement) { }, authProviders: Array, clientId: String, - clientSecret: String, }; } connectedCallback() { super.connectedCallback(); - fetch('/auth/providers', { - headers: { - Authorization: `Basic ${btoa(`${this.clientId}:${this.clientSecret}`)}` - } - }).then((response) => { + fetch('/auth/providers').then((response) => { if (!response.ok) throw new Error(); return response.json(); }).then((authProviders) => { diff --git a/src/common/auth/fetch_token.js b/src/common/auth/fetch_token.js index 17c47fa8a7..6fe6933598 100644 --- a/src/common/auth/fetch_token.js +++ b/src/common/auth/fetch_token.js @@ -1,12 +1,10 @@ export default function fetchToken(clientId, code) { const data = new FormData(); + data.append('client_id', clientId); data.append('grant_type', 'authorization_code'); data.append('code', code); return fetch('/auth/token', { method: 'POST', - headers: { - authorization: `Basic ${btoa(clientId)}` - }, body: data, }).then((resp) => { if (!resp.ok) throw new Error('Unable to fetch tokens'); diff --git a/src/common/auth/refresh_token.js b/src/common/auth/refresh_token.js index d7d20e4a97..dabfbd358b 100644 --- a/src/common/auth/refresh_token.js +++ b/src/common/auth/refresh_token.js @@ -1,12 +1,10 @@ export default function refreshAccessToken(clientId, refreshToken) { const data = new FormData(); + data.append('client_id', clientId); data.append('grant_type', 'refresh_token'); data.append('refresh_token', refreshToken); return fetch('/auth/token', { method: 'POST', - headers: { - authorization: `Basic ${btoa(clientId)}` - }, body: data, }).then((resp) => { if (!resp.ok) throw new Error('Unable to fetch tokens'); diff --git a/src/entrypoints/authorize.js b/src/entrypoints/authorize.js index 833732bfaa..3fcde70c4a 100644 --- a/src/entrypoints/authorize.js +++ b/src/entrypoints/authorize.js @@ -19,11 +19,22 @@ class HaAuthorize extends PolymerElement {
Logging in to [[clientId]].
+ -