Skip to content

Commit 02d1a0b

Browse files
authored
[teslascope] remove deprecated apiKey support (#21396)
* Remove apiKey support Signed-off-by: Paul Smedley <paul@smedley.id.au>
1 parent 36e6944 commit 02d1a0b

6 files changed

Lines changed: 20 additions & 59 deletions

File tree

bundles/org.openhab.binding.teslascope/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@ Account configuration is necessary.
1818
The easiest way to do this is from the UI.
1919
Just add a new Thing, select the Teslascope binding, then Teslascope Account Binding Thing, and enter the personalAccessToken which can be generated from the Teslascope website.
2020

21-
As a minimum, the personalAccessToken or API key (deprecated) is needed:
21+
As a minimum, the personalAccessToken is needed:
2222

2323
| Thing Parameter | Default Value | Required | Advanced | Description |
2424
|---------------------|---------------|----------|----------|--------------------------------------------------------------------------------------|
25-
| apiKey | N/A | No | No | API Key from the Teslascope website (deprecated) |
26-
| personalAccessToken | N/A | No | No | Personal Access Token generated from the Teslascope website |
25+
| personalAccessToken | N/A | Yes | No | Personal Access Token generated from the Teslascope website |
2726
| refreshInterval | 60 | No | Yes | The frequency with which to refresh information from Teslascope specified in seconds |
2827

2928
## `vehicle` Thing Configuration

bundles/org.openhab.binding.teslascope/src/main/java/org/openhab/binding/teslascope/internal/TeslascopeAccountConfiguration.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@
2121
*/
2222
@NonNullByDefault
2323
public class TeslascopeAccountConfiguration {
24-
/**
25-
* Teslascope is phasing out support for apiKey in lieu of Personal Access Tokens
26-
*/
27-
@Deprecated
28-
public String apiKey = "";
2924
public String personalAccessToken = "";
3025
public int refreshInterval = 60;
3126
}

bundles/org.openhab.binding.teslascope/src/main/java/org/openhab/binding/teslascope/internal/TeslascopeAccountHandler.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public String getVehicleList() {
6969
TeslascopeAccountConfiguration config = this.config;
7070
if (config != null) {
7171
try {
72-
return webTargets.getVehicleList(config.apiKey, config.personalAccessToken);
72+
return webTargets.getVehicleList(config.personalAccessToken);
7373
} catch (TeslascopeAuthenticationException e) {
7474
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
7575
"Authentication problem: " + e.getMessage());
@@ -85,7 +85,7 @@ public String getDetailedInformation(String publicID)
8585
throws TeslascopeCommunicationException, TeslascopeAuthenticationException {
8686
TeslascopeAccountConfiguration config = this.config;
8787
if (config != null) {
88-
return webTargets.getDetailedInformation(publicID, config.apiKey, config.personalAccessToken);
88+
return webTargets.getDetailedInformation(publicID, config.personalAccessToken);
8989
}
9090
return "";
9191
}
@@ -94,15 +94,15 @@ public void sendCommand(String publicID, String command)
9494
throws TeslascopeCommunicationException, TeslascopeAuthenticationException {
9595
TeslascopeAccountConfiguration config = this.config;
9696
if (config != null) {
97-
webTargets.sendCommand(publicID, config.apiKey, config.personalAccessToken, command);
97+
webTargets.sendCommand(publicID, config.personalAccessToken, command);
9898
}
9999
}
100100

101101
public void sendCommand(String publicID, String command, String params)
102102
throws TeslascopeCommunicationException, TeslascopeAuthenticationException {
103103
TeslascopeAccountConfiguration config = this.config;
104104
if (config != null) {
105-
webTargets.sendCommand(publicID, config.apiKey, config.personalAccessToken, command, params);
105+
webTargets.sendCommand(publicID, config.personalAccessToken, command, params);
106106
}
107107
}
108108

@@ -114,11 +114,7 @@ public void handleCommand(ChannelUID channelUID, Command command) {
114114
@Override
115115
public void initialize() {
116116
TeslascopeAccountConfiguration localConfig = config = getConfigAs(TeslascopeAccountConfiguration.class);
117-
if (!localConfig.apiKey.isBlank() && localConfig.personalAccessToken.isBlank()) {
118-
logger.warn(
119-
"ApiKey is deprecated and is expected to stop working in late 2026. Please migrate to a Personal Access Token.");
120-
}
121-
if (localConfig.apiKey.isBlank() && localConfig.personalAccessToken.isBlank()) {
117+
if (localConfig.personalAccessToken.isBlank()) {
122118
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
123119
"@text/offline.conf-error.no-credentials");
124120
return;

bundles/org.openhab.binding.teslascope/src/main/java/org/openhab/binding/teslascope/internal/TeslascopeWebTargets.java

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -45,53 +45,32 @@ public TeslascopeWebTargets(HttpClient httpClient) {
4545
this.httpClient = httpClient;
4646
}
4747

48-
public String getVehicleList(String apiKey, String personalAccessToken)
48+
public String getVehicleList(String personalAccessToken)
4949
throws TeslascopeCommunicationException, TeslascopeAuthenticationException {
50-
if (personalAccessToken.isBlank()) {
51-
return invoke(BASE_URI + "vehicles?api_key=" + apiKey, HttpMethod.GET, "");
52-
} else {
53-
return invoke(BASE_URI + "vehicles", HttpMethod.GET, personalAccessToken);
54-
}
50+
return invoke(BASE_URI + "vehicles", HttpMethod.GET, personalAccessToken);
5551
}
5652

57-
public String getDetailedInformation(String publicID, String apiKey, String personalAccessToken)
53+
public String getDetailedInformation(String publicID, String personalAccessToken)
5854
throws TeslascopeCommunicationException, TeslascopeAuthenticationException {
59-
if (personalAccessToken.isBlank()) {
60-
return invoke(BASE_VEHICLE_URI + publicID + "/detailed?api_key=" + apiKey, HttpMethod.GET, "");
61-
} else {
62-
return invoke(BASE_VEHICLE_URI + publicID + "/detailed", HttpMethod.GET, personalAccessToken);
63-
}
55+
return invoke(BASE_VEHICLE_URI + publicID + "/detailed", HttpMethod.GET, personalAccessToken);
6456
}
6557

66-
public void sendCommand(String publicID, String apiKey, String personalAccessToken, String command)
58+
public void sendCommand(String publicID, String personalAccessToken, String command)
6759
throws TeslascopeCommunicationException, TeslascopeAuthenticationException {
68-
if (personalAccessToken.isBlank()) {
69-
invoke(BASE_VEHICLE_URI + publicID + "/command/" + command + "?api_key=" + apiKey, HttpMethod.POST, "");
70-
} else {
71-
invoke(BASE_VEHICLE_URI + publicID + "/command/" + command, HttpMethod.POST, personalAccessToken);
72-
}
60+
invoke(BASE_VEHICLE_URI + publicID + "/command/" + command, HttpMethod.POST, personalAccessToken);
7361
return;
7462
}
7563

76-
public void sendCommand(String publicID, String apiKey, String personalAccessToken, String command, String params)
64+
public void sendCommand(String publicID, String personalAccessToken, String command, String params)
7765
throws TeslascopeCommunicationException, TeslascopeAuthenticationException {
7866
String cleanParams = (params == null) ? "" : params.replaceFirst("^[?&]", "");
7967

80-
if (personalAccessToken.isBlank()) {
81-
// Legacy API Key method (needs & separator because ? is already used)
82-
String url = BASE_VEHICLE_URI + publicID + "/command/" + command + "?api_key=" + apiKey;
83-
if (!cleanParams.isEmpty()) {
84-
url += "&" + cleanParams;
85-
}
86-
invoke(url, HttpMethod.POST, "");
87-
} else {
88-
// Personal Access Token method (needs ? separator)
89-
String url = BASE_VEHICLE_URI + publicID + "/command/" + command;
90-
if (!cleanParams.isEmpty()) {
91-
url += "?" + cleanParams;
92-
}
93-
invoke(url, HttpMethod.POST, personalAccessToken);
68+
// Personal Access Token method (needs ? separator)
69+
String url = BASE_VEHICLE_URI + publicID + "/command/" + command;
70+
if (!cleanParams.isEmpty()) {
71+
url += "?" + cleanParams;
9472
}
73+
invoke(url, HttpMethod.POST, personalAccessToken);
9574
}
9675

9776
private String invoke(String uri, HttpMethod method, String personalAccessToken)

bundles/org.openhab.binding.teslascope/src/main/resources/OH-INF/i18n/teslascope.properties

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ thing-type.teslascope.vehicle.description = Access to Tesla Vehicle data via the
1212

1313
# thing types config
1414

15-
thing-type.config.teslascope.account.apiKey.label = apiKey
16-
thing-type.config.teslascope.account.apiKey.description = apiKey provided by Teslascope (Deprecated - use Personal Access Token instead)
1715
thing-type.config.teslascope.account.personalAccessToken.label = Personal Access Token
1816
thing-type.config.teslascope.account.personalAccessToken.description = Personal Access Token provided by Teslascope
1917
thing-type.config.teslascope.account.refreshInterval.label = Refresh Interval
@@ -203,8 +201,6 @@ thing-type.teslascope.service.description = Access to Tesla Vehicle data via the
203201

204202
# thing types config
205203

206-
thing-type.config.teslascope.service.apiKey.label = apiKey
207-
thing-type.config.teslascope.service.apiKey.description = apiKey provided by Teslascope
208204
thing-type.config.teslascope.service.publicID.label = Vehicle Public ID
209205
thing-type.config.teslascope.service.publicID.description = Vehicle public ID listed in Teslascope
210206
thing-type.config.teslascope.service.refreshInterval.label = Refresh Interval

bundles/org.openhab.binding.teslascope/src/main/resources/OH-INF/thing/thing-types.xml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@
99
<description>Access to Tesla Vehicle data via the Teslascope developer API</description>
1010
<semantic-equipment-tag>WebService</semantic-equipment-tag>
1111
<config-description>
12-
<parameter name="apiKey" type="text" required="false">
13-
<label>apiKey</label>
14-
<description>apiKey provided by Teslascope (Deprecated - use Personal Access Token instead)</description>
15-
</parameter>
16-
<parameter name="personalAccessToken" type="text" required="false">
12+
<parameter name="personalAccessToken" type="text" required="true">
1713
<label>Personal Access Token</label>
1814
<description>Personal Access Token provided by Teslascope</description>
1915
</parameter>

0 commit comments

Comments
 (0)