From: Samy Date: Sat, 12 Nov 2022 20:55:45 +0000 (+0100) Subject: Upgrade Mercedes API usage for authentication & tokens retrieval X-Git-Tag: v0.12~5^2 X-Git-Url: http://git.giorgioravera.it/?a=commitdiff_plain;h=7f28cb446520d2ded5c5229a5ee338b84b9f7724;p=mercedes_me_api.git Upgrade Mercedes API usage for authentication & tokens retrieval --- diff --git a/const.py b/const.py index 7967c05..4134f20 100644 --- a/const.py +++ b/const.py @@ -16,7 +16,7 @@ CONFIG_FILE = ".mercedesme_config" RESOURCES_FILE = ".mercedesme_resources" # Mercedes me Application Parameters REDIRECT_URL = "https://localhost" -SCOPE = "mb:vehicle:mbdata:fuelstatus%20mb:vehicle:mbdata:vehiclestatus%20mb:vehicle:mbdata:vehiclelock%20mb:vehicle:mbdata:evstatus%20mb:vehicle:mbdata:payasyoudrive%20offline_access" +SCOPE = "openid%20mb:vehicle:mbdata:fuelstatus%20mb:vehicle:mbdata:vehiclestatus%20mb:vehicle:mbdata:vehiclelock%20mb:vehicle:mbdata:evstatus%20mb:vehicle:mbdata:payasyoudrive%20offline_access" URL_RES_PREFIX = "https://api.mercedes-benz.com/vehicledata/v2" # Configuration File Parameters diff --git a/custom_components/mercedesmeapi/const.py b/custom_components/mercedesmeapi/const.py index f9cbe81..c7128de 100644 --- a/custom_components/mercedesmeapi/const.py +++ b/custom_components/mercedesmeapi/const.py @@ -15,7 +15,7 @@ TOKEN_FILE = ".mercedesme_token" RESOURCES_FILE = ".mercedesme_resources" # Mercedes me Application Parameters REDIRECT_URL = "https://localhost" -SCOPE = "mb:vehicle:mbdata:fuelstatus%20mb:vehicle:mbdata:vehiclestatus%20mb:vehicle:mbdata:vehiclelock%20mb:vehicle:mbdata:evstatus%20mb:vehicle:mbdata:payasyoudrive%20offline_access" +SCOPE = "openid%20mb:vehicle:mbdata:fuelstatus%20mb:vehicle:mbdata:vehiclestatus%20mb:vehicle:mbdata:vehiclelock%20mb:vehicle:mbdata:evstatus%20mb:vehicle:mbdata:payasyoudrive%20offline_access" URL_RES_PREFIX = "https://api.mercedes-benz.com/vehicledata/v2" #UPDATE_SIGNAL = "mercedesmeapi_update" diff --git a/custom_components/mercedesmeapi/oauth.py b/custom_components/mercedesmeapi/oauth.py index 3e34214..35dc7c0 100644 --- a/custom_components/mercedesmeapi/oauth.py +++ b/custom_components/mercedesmeapi/oauth.py @@ -14,9 +14,9 @@ import os from .const import * from .query import * -URL_OAUTH_BASE = "https://id.mercedes-benz.com/as" -URL_OAUTH_AUTH = f"{URL_OAUTH_BASE}/authorization.oauth2?response_type=code" -URL_OAUTH_TOKEN = f"{URL_OAUTH_BASE}/token.oauth2" +URL_OAUTH_BASE = "https://ssoalpha.dvb.corpinter.net/v1" +URL_OAUTH_AUTH = f"{URL_OAUTH_BASE}/auth?response_type=code" +URL_OAUTH_TOKEN = f"{URL_OAUTH_BASE}/token" # Logger _LOGGER = logging.getLogger(__name__) diff --git a/mercedes_me_api.sh b/mercedes_me_api.sh index 18419d5..c41d8a2 100755 --- a/mercedes_me_api.sh +++ b/mercedes_me_api.sh @@ -21,7 +21,7 @@ TOKEN_FILE=".mercedesme_token" CONFIG_FILE=".mercedesme_config" # Mercedes me Application Parameters REDIRECT_URL="https://localhost" -SCOPE="mb:vehicle:mbdata:fuelstatus%20mb:vehicle:mbdata:vehiclestatus%20mb:vehicle:mbdata:vehiclelock%20mb:vehicle:mbdata:evstatus%20mb:vehicle:mbdata:payasyoudrive%20offline_access" +SCOPE="openid%20mb:vehicle:mbdata:fuelstatus%20mb:vehicle:mbdata:vehiclestatus%20mb:vehicle:mbdata:vehiclelock%20mb:vehicle:mbdata:evstatus%20mb:vehicle:mbdata:payasyoudrive%20offline_access" RES_URL_PREFIX="https://api.mercedes-benz.com/vehicledata/v2" # Resources RES_FUEL=(rangeliquid tanklevelpercent) @@ -50,7 +50,7 @@ VEHICLE_ID="" if [[ -f "$CONFIG_FILE" ]]; then . $CONFIG_FILE fi -if [ -z $CLIENT_ID ] | [ -z $CLIENT_ID ] | [ -z $CLIENT_ID ]; then +if [ -z $CLIENT_ID ] | [ -z $CLIENT_SECRET ] | [ -z $VEHICLE_ID ]; then echo "Please create $CONFIG_FILE with CLIENT_ID=\"\", CLIENT_SECRET=\"\", VEHICLE_ID=\"\"" exit fi @@ -139,15 +139,15 @@ function getAuthCode () echo "Open the browser and insert this link:" echo - echo "https://id.mercedes-benz.com/as/authorization.oauth2?response_type=code&client_id=$CLIENT_ID&redirect_uri=$REDIRECT_URL&scope=$SCOPE" - #echo "https://id.mercedes-benz.com/as/authorization.oauth2?response_type=code&client_id=$CLIENT_ID&redirect_uri=$REDIRECT_URL&scope=$SCOPE&state=$STATE" + echo "https://ssoalpha.dvb.corpinter.net/v1/auth?response_type=code&client_id=$CLIENT_ID&redirect_uri=$REDIRECT_URL&scope=$SCOPE" + #echo "https://ssoalpha.dvb.corpinter.net/v1/auth?response_type=code&client_id=$CLIENT_ID&redirect_uri=$REDIRECT_URL&scope=$SCOPE&state=$STATE" echo echo "Copy the code in the url:" read AUTH_CODE TOKEN=$(curl --request POST \ - --url https://id.mercedes-benz.com/as/token.oauth2 \ + --url https://ssoalpha.dvb.corpinter.net/v1/token \ --header "Authorization: Basic $BASE64" \ --header "content-type: application/x-www-form-urlencoded" \ --data "grant_type=authorization_code&code=$AUTH_CODE&redirect_uri=$REDIRECT_URL") diff --git a/oauth.py b/oauth.py index ea35f0d..7a2a075 100644 --- a/oauth.py +++ b/oauth.py @@ -14,9 +14,9 @@ import os from const import * from query import * -URL_OAUTH_BASE = "https://id.mercedes-benz.com/as" -URL_OAUTH_AUTH = f"{URL_OAUTH_BASE}/authorization.oauth2?response_type=code" -URL_OAUTH_TOKEN = f"{URL_OAUTH_BASE}/token.oauth2" +URL_OAUTH_BASE = "https://ssoalpha.dvb.corpinter.net/v1" +URL_OAUTH_AUTH = f"{URL_OAUTH_BASE}/auth?response_type=code" +URL_OAUTH_TOKEN = f"{URL_OAUTH_BASE}/token" # Logger _LOGGER = logging.getLogger(__name__)