]> git.giorgioravera.it Git - mercedes_me_api.git/commitdiff
Upgrade Mercedes API usage for authentication & tokens retrieval
authorSamy <samyabbas31@gmail.com>
Sat, 12 Nov 2022 20:55:45 +0000 (21:55 +0100)
committerSamy <samyabbas31@gmail.com>
Sat, 12 Nov 2022 21:04:57 +0000 (22:04 +0100)
const.py
custom_components/mercedesmeapi/const.py
custom_components/mercedesmeapi/oauth.py
mercedes_me_api.sh
oauth.py

index 7967c05795763aca0b834da930555c8a82459e48..4134f2000d5b0c3029fb0570e2dbc1e3196bf945 100644 (file)
--- 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
index f9cbe81f67c7ff866b07c0720c6e88588a6fbeb2..c7128de13e3ff10f2510a5a0a042eb15bfde336b 100644 (file)
@@ -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"
 
index 3e34214ea24355d6c0663c251c76d0f53705780e..35dc7c098b6bafd2ead81757634b365672305443 100644 (file)
@@ -14,9 +14,9 @@ import os
 from .const import *\r
 from .query import *\r
 \r
-URL_OAUTH_BASE = "https://id.mercedes-benz.com/as"\r
-URL_OAUTH_AUTH = f"{URL_OAUTH_BASE}/authorization.oauth2?response_type=code"\r
-URL_OAUTH_TOKEN = f"{URL_OAUTH_BASE}/token.oauth2"\r
+URL_OAUTH_BASE = "https://ssoalpha.dvb.corpinter.net/v1"\r
+URL_OAUTH_AUTH = f"{URL_OAUTH_BASE}/auth?response_type=code"\r
+URL_OAUTH_TOKEN = f"{URL_OAUTH_BASE}/token"\r
 \r
 # Logger\r
 _LOGGER = logging.getLogger(__name__)\r
index 18419d5adfc3da9b8564b9aa1d25fc2d37aab1ec..c41d8a209f98181453a0abf5a3f22b73e381ca79 100755 (executable)
@@ -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")
index ea35f0d78d4c051ee0e41d7a959f840eabb1c0f8..7a2a07578ba8c354d847bc7237f50fd99eedebd4 100644 (file)
--- 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__)