Force https for oauth

This commit is contained in:
Yegor Vialov 2020-01-29 17:38:51 +00:00
parent 831fc98ab1
commit 9303e4c0a5
2 changed files with 4 additions and 4 deletions

View File

@ -14,7 +14,7 @@ class AuthManager {
Completer completer = Completer();
final flutterWebviewPlugin = new FlutterWebviewPlugin();
flutterWebviewPlugin.onUrlChanged.listen((String url) {
if (url.startsWith("http://ha-client.estevez.dev/service/auth_callback.html")) {
if (url.startsWith("https://ha-client.estevez.dev/service/auth_callback.html")) {
Logger.d("url=$url");
String authCode = url.split("=")[1];
Logger.d("authCode=$authCode");
@ -23,7 +23,7 @@ class AuthManager {
endPoint: "/auth/token",
contentType: "application/x-www-form-urlencoded",
includeAuthHeader: false,
data: "grant_type=authorization_code&code=$authCode&client_id=${Uri.encodeComponent('http://ha-client.estevez.dev')}"
data: "grant_type=authorization_code&code=$authCode&client_id=${Uri.encodeComponent('https://ha-client.estevez.dev')}"
).then((response) {
Logger.d("Got temp token");
String tempToken = json.decode(response)['access_token'];

View File

@ -59,9 +59,9 @@ class ConnectionManager {
_token = await storage.read(key: "hacl_llt");
Logger.e("Long-lived token read successful");
oauthUrl = "$httpWebHost/auth/authorize?client_id=${Uri.encodeComponent(
'http://ha-client.estevez.dev')}&redirect_uri=${Uri
'https://ha-client.estevez.dev')}&redirect_uri=${Uri
.encodeComponent(
'http://ha-client.estevez.dev/service/auth_callback.html')}";
'https://ha-client.estevez.dev/service/auth_callback.html')}";
settingsLoaded = true;
} catch (e) {
completer.completeError(HAError("Error reading login details", actions: [HAErrorAction.tryAgain(type: HAErrorActionType.FULL_RELOAD), HAErrorAction.loginAgain()]));