[mercedesme] New API Migration (#13670)

* adjust servers and scope
* ensure IPv4 address for callback

Signed-off-by: Bernd Weymann <bernd.weymann@gmail.com>
This commit is contained in:
Bernd Weymann 2022-11-07 18:48:48 +01:00 committed by GitHub
parent bf804ce42c
commit 51f1c0978b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 4 deletions

View File

@ -48,8 +48,8 @@ public class Constants {
public static final String GROUP_LOCATION = "location";
public static final String GROUP_IMAGE = "image";
public static final String MB_AUTH_URL = "https://id.mercedes-benz.com/as/authorization.oauth2";
public static final String MB_TOKEN_URL = "https://id.mercedes-benz.com/as/token.oauth2";
public static final String MB_AUTH_URL = "https://ssoalpha.dvb.corpinter.net/v1/auth";
public static final String MB_TOKEN_URL = "https://ssoalpha.dvb.corpinter.net/v1/token";
public static final String CALLBACK_ENDPOINT = "/mb-callback";
public static final String OAUTH_CLIENT_NAME = "#byocar";
@ -64,6 +64,7 @@ public class Constants {
// https://developer.mercedes-benz.com/products/vehicle_status/docs
public static final String SCOPE_STATUS = "mb:vehicle:mbdata:vehiclestatus";
public static final String SCOPE_OFFLINE = "offline_access";
public static final String SCOPE_OPENID = "openid";
public static final String BASE_URL = "https://api.mercedes-benz.com/vehicledata/v2";
public static final String ODO_URL = BASE_URL + "/vehicles/%s/containers/payasyoudrive";

View File

@ -40,7 +40,7 @@ public class AccountConfiguration {
// https://developer.mercedes-benz.com/products/electric_vehicle_status/docs#_required_scopes
public String getScope() {
StringBuffer sb = new StringBuffer();
sb.append(SCOPE_OFFLINE);
sb.append(SCOPE_OPENID).append(SPACE).append(SCOPE_OFFLINE);
if (odoScope) {
sb.append(SPACE).append(SCOPE_ODO);
}

View File

@ -61,6 +61,7 @@ public class Utils {
}
public static String getCallbackIP() throws SocketException {
// https://stackoverflow.com/questions/901755/how-to-get-the-ip-of-the-computer-on-linux-through-java
// https://stackoverflow.com/questions/1062041/ip-address-not-obtained-in-java
for (Enumeration<NetworkInterface> ifaces = NetworkInterface.getNetworkInterfaces(); ifaces
.hasMoreElements();) {

View File

@ -36,7 +36,7 @@ class ConfigurationTest {
void testScope() {
AccountConfiguration ac = new AccountConfiguration();
assertEquals(
"offline_access mb:vehicle:mbdata:payasyoudrive mb:vehicle:mbdata:vehiclestatus mb:vehicle:mbdata:vehiclelock mb:vehicle:mbdata:fuelstatus mb:vehicle:mbdata:evstatus",
"openid offline_access mb:vehicle:mbdata:payasyoudrive mb:vehicle:mbdata:vehiclestatus mb:vehicle:mbdata:vehiclelock mb:vehicle:mbdata:fuelstatus mb:vehicle:mbdata:evstatus",
ac.getScope());
}