fixed refresh token setup
parent
49dfec019f
commit
76763ad5d9
|
|
@ -20,6 +20,18 @@ Home connected home appliances, like:
|
||||||
* Internet connection
|
* Internet connection
|
||||||
* Home connect account
|
* Home connect account
|
||||||
|
|
||||||
|
## Plug-In Settings
|
||||||
|
|
||||||
|
**Simulation Mode**
|
||||||
|
HomeConnect has a simulation server, where the home appliances are simulated. This feature is useful for demonstration and development.
|
||||||
|
|
||||||
|
**Control**
|
||||||
|
The control of the oven for example is only allowed with an authorized API key. The nymea community
|
||||||
|
API credentials does not have this permission. Enabling this without the permission will result in failing login attempts.
|
||||||
|
|
||||||
|
**Custom client key and secret**
|
||||||
|
You can register as developer on https://developer.home-connect.com, where you can obtain you own client credentials. The default client credentials are made available through the nymea community API key provider.
|
||||||
|
|
||||||
## More
|
## More
|
||||||
|
|
||||||
Home Connect developer documentation:
|
Home Connect developer documentation:
|
||||||
|
|
|
||||||
|
|
@ -224,6 +224,7 @@ void HomeConnect::getAccessTokenFromRefreshToken(const QByteArray &refreshToken)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_accessToken = data.toVariant().toMap().value("access_token").toByteArray();
|
m_accessToken = data.toVariant().toMap().value("access_token").toByteArray();
|
||||||
|
emit receivedAccessToken(m_accessToken);
|
||||||
|
|
||||||
if (data.toVariant().toMap().contains("expires_in")) {
|
if (data.toVariant().toMap().contains("expires_in")) {
|
||||||
int expireTime = data.toVariant().toMap().value("expires_in").toInt();
|
int expireTime = data.toVariant().toMap().value("expires_in").toInt();
|
||||||
|
|
@ -279,7 +280,9 @@ void HomeConnect::getAccessTokenFromAuthorizationCode(const QByteArray &authoriz
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_accessToken = jsonDoc.toVariant().toMap().value("access_token").toByteArray();
|
m_accessToken = jsonDoc.toVariant().toMap().value("access_token").toByteArray();
|
||||||
|
receivedAccessToken(m_accessToken);
|
||||||
m_refreshToken = jsonDoc.toVariant().toMap().value("refresh_token").toByteArray();
|
m_refreshToken = jsonDoc.toVariant().toMap().value("refresh_token").toByteArray();
|
||||||
|
receivedRefreshToken(m_refreshToken);
|
||||||
|
|
||||||
if (jsonDoc.toVariant().toMap().contains("expires_in")) {
|
if (jsonDoc.toVariant().toMap().contains("expires_in")) {
|
||||||
int expireTime = jsonDoc.toVariant().toMap().value("expires_in").toInt();
|
int expireTime = jsonDoc.toVariant().toMap().value("expires_in").toInt();
|
||||||
|
|
|
||||||
|
|
@ -172,6 +172,8 @@ private slots:
|
||||||
signals:
|
signals:
|
||||||
void connectionChanged(bool connected);
|
void connectionChanged(bool connected);
|
||||||
void authenticationStatusChanged(bool authenticated);
|
void authenticationStatusChanged(bool authenticated);
|
||||||
|
void receivedRefreshToken(const QByteArray &refreshToken);
|
||||||
|
void receivedAccessToken(const QByteArray &accessToken);
|
||||||
void commandExecuted(const QUuid &commandId, bool success);
|
void commandExecuted(const QUuid &commandId, bool success);
|
||||||
|
|
||||||
void receivedHomeAppliances(const QList<HomeAppliance> &appliances);
|
void receivedHomeAppliances(const QList<HomeAppliance> &appliances);
|
||||||
|
|
|
||||||
|
|
@ -188,19 +188,8 @@ void IntegrationPluginHomeConnect::confirmPairing(ThingPairingInfo *info, const
|
||||||
}
|
}
|
||||||
qCDebug(dcHomeConnect()) << "Authorization code" << authorizationCode;
|
qCDebug(dcHomeConnect()) << "Authorization code" << authorizationCode;
|
||||||
homeConnect->getAccessTokenFromAuthorizationCode(authorizationCode);
|
homeConnect->getAccessTokenFromAuthorizationCode(authorizationCode);
|
||||||
connect(homeConnect, &HomeConnect::authenticationStatusChanged, this, [info, this](bool authenticated){
|
connect(homeConnect, &HomeConnect::receivedRefreshToken, info, [info, this](const QByteArray &refreshToken){
|
||||||
HomeConnect *homeConnect = static_cast<HomeConnect *>(sender());
|
qCDebug(dcHomeConnect()) << "Token:" << refreshToken;
|
||||||
|
|
||||||
if(!authenticated) {
|
|
||||||
qWarning(dcHomeConnect()) << "Authentication process failed";
|
|
||||||
m_setupHomeConnectConnections.remove(info->thingId());
|
|
||||||
homeConnect->deleteLater();
|
|
||||||
info->finish(Thing::ThingErrorSetupFailed);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
QByteArray accessToken = homeConnect->accessToken();
|
|
||||||
QByteArray refreshToken = homeConnect->refreshToken();
|
|
||||||
qCDebug(dcHomeConnect()) << "Token:" << accessToken << refreshToken;
|
|
||||||
|
|
||||||
pluginStorage()->beginGroup(info->thingId().toString());
|
pluginStorage()->beginGroup(info->thingId().toString());
|
||||||
pluginStorage()->setValue("refresh_token", refreshToken);
|
pluginStorage()->setValue("refresh_token", refreshToken);
|
||||||
|
|
|
||||||
|
|
@ -5,20 +5,20 @@
|
||||||
<name>IntegrationPluginHomeConnect</name>
|
<name>IntegrationPluginHomeConnect</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../integrationpluginhomeconnect.cpp" line="154"/>
|
<location filename="../integrationpluginhomeconnect.cpp" line="154"/>
|
||||||
<location filename="../integrationpluginhomeconnect.cpp" line="246"/>
|
<location filename="../integrationpluginhomeconnect.cpp" line="235"/>
|
||||||
<source>Client key and/or seceret is not available.</source>
|
<source>Client key and/or seceret is not available.</source>
|
||||||
<translation>Client key oder Secret ist nicht verfügbar</translation>
|
<translation>Client key oder Secret sind nicht verfügbar</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../integrationpluginhomeconnect.cpp" line="236"/>
|
<location filename="../integrationpluginhomeconnect.cpp" line="225"/>
|
||||||
<source>Refresh token is not available.</source>
|
<source>Refresh token is not available.</source>
|
||||||
<translation>Refresh token ist nicht verfügbar.</translation>
|
<translation>Refresh token ist nicht verfügbar.</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../integrationpluginhomeconnect.cpp" line="414"/>
|
<location filename="../integrationpluginhomeconnect.cpp" line="403"/>
|
||||||
<location filename="../integrationpluginhomeconnect.cpp" line="429"/>
|
<location filename="../integrationpluginhomeconnect.cpp" line="418"/>
|
||||||
<location filename="../integrationpluginhomeconnect.cpp" line="448"/>
|
<location filename="../integrationpluginhomeconnect.cpp" line="437"/>
|
||||||
<location filename="../integrationpluginhomeconnect.cpp" line="461"/>
|
<location filename="../integrationpluginhomeconnect.cpp" line="450"/>
|
||||||
<source>Please select a program first</source>
|
<source>Please select a program first</source>
|
||||||
<translation>Bitte wählen Sie zuerst ein Programm aus</translation>
|
<translation>Bitte wählen Sie zuerst ein Programm aus</translation>
|
||||||
</message>
|
</message>
|
||||||
|
|
|
||||||
|
|
@ -5,20 +5,20 @@
|
||||||
<name>IntegrationPluginHomeConnect</name>
|
<name>IntegrationPluginHomeConnect</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../integrationpluginhomeconnect.cpp" line="154"/>
|
<location filename="../integrationpluginhomeconnect.cpp" line="154"/>
|
||||||
<location filename="../integrationpluginhomeconnect.cpp" line="246"/>
|
<location filename="../integrationpluginhomeconnect.cpp" line="235"/>
|
||||||
<source>Client key and/or seceret is not available.</source>
|
<source>Client key and/or seceret is not available.</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../integrationpluginhomeconnect.cpp" line="236"/>
|
<location filename="../integrationpluginhomeconnect.cpp" line="225"/>
|
||||||
<source>Refresh token is not available.</source>
|
<source>Refresh token is not available.</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../integrationpluginhomeconnect.cpp" line="414"/>
|
<location filename="../integrationpluginhomeconnect.cpp" line="403"/>
|
||||||
<location filename="../integrationpluginhomeconnect.cpp" line="429"/>
|
<location filename="../integrationpluginhomeconnect.cpp" line="418"/>
|
||||||
<location filename="../integrationpluginhomeconnect.cpp" line="448"/>
|
<location filename="../integrationpluginhomeconnect.cpp" line="437"/>
|
||||||
<location filename="../integrationpluginhomeconnect.cpp" line="461"/>
|
<location filename="../integrationpluginhomeconnect.cpp" line="450"/>
|
||||||
<source>Please select a program first</source>
|
<source>Please select a program first</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue