|
发表于 2020-10-21 10:02:13
|
显示全部楼层
然后我是领克03,以前抓包的时候看了下,接口登录地址,token获取地址和你那的不一样
def grant_token(self):
""" 获取Token """
return self.post(
url = "https://sso.lynkco.com/uaa/obtainToken",
json = {
"device_id": "08bc8ccb41dd42d3aae5569ae2fe78f6",
"type":"2",
"category":"10",
"username": self.UserName,
"password": self.PassWord
},
headers = {
"Host": "sso.lynkco.com",
"Content-Type": "application/json",
"Cookie": "appKey=557284c1-c972-4e14-82f7-092897a5b3da",
"Connection": "keep-alive",
"Accept": "*/*",
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 8_3 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12F70 Safari/600.1.4",
"Accept-Language": "zh-Hans-CN;q=1",
"Content-Length": "122",
"Accept-Encoding": "br,gzip,deflate"
}
)
def getAuthCode(self):
""" 返回获取AuthCode """
if self.token:
now = time.time()
if self.token_expires - now > 60:
json = self.grant_AuthCode()
self.AuthCode = json["code"]
return self.AuthCode
json = self.getToken()
json = self.grant_AuthCode()
self.AuthCode = json["code"]
return self.AuthCode
def grant_AuthCode(self):
"""获取认证码"""
return self.post(
url = "https://sso.lynkco.com/oauth2/appcode?access_token=" + self.token,
headers = {
"Host": "sso.lynkco.com",
"Content-Type": "application/json",
"Cookie": "last-sid=" + self.token + "; sid=" + self.token + "; appKey=557284c1-c972-4e14-82f7-092897a5b3da; acw_tc=314fef1815508059561902533e63d6c42ca0f98d6c78b00379916f49f7",
"Connection": "keep-alive",
"Accept": "*/*",
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 8_3 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12F70 Safari/600.1.4",
"Accept-Language": "zh-Hans-CN;q=1",
"Content-Length": "146",
"Accept-Encoding": "br, gzip, deflate"
},
json = {
"response_type":"code",
"scope":"openid",
"redirect_uri":"http://www.abcde.com",
"client_id":"1223fa55b0e04d39bd395b12db16d6ab",
"state":"test123"
}
)
def getCarToken(self):
""" 返回获取汽车Token """
if self.AuthCode:
if self.grant_CarToken:
now = time.time()
if self.CarToken_expires - now > 60:
return self.grant_CarToken
json = self.grant_CarToken()
self.CarToken = json['data']["accessToken"]
self.UserId = json['data']['userId']
self.CarToken_expires = time.time() + int(json['data']['expiresIn'])
return self.CarToken
json = self.getAuthCode()
json = self.grant_CarToken()
self.CarToken = json['data']["accessToken"]
self.UserId = json['data']['userId']
self.CarToken_expires = time.time() + int(json['data']['expiresIn'])
return self.CarToken
def grant_CarToken(self):
"""获取汽车Token"""
return self.post(
url = "https://api.xchanger.cn/auth/account/session?identity_type=lid",
headers = {
"Host": "api.xchanger.cn",
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 8_3 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12F70 Safari/600.1.4",
"X-APP-ID": "lynkco",
"X-DEVICE-MODEL": "iPhone",
"X-DEVICE-TYPE": "mobile",
"X-DEVICE-MANUFACTURE": "APPLE",
"X-AGENT-TYPE": "ios",
"X-CLIENT-ID": "APPLE0000APP00IPHONE191Q05659476",
"Content-Length": "86",
"PLATFORM": "CMA",
"X-ENV-TYPE": "production",
"X-SIGN": "jGBWHFziVx55QHEMBT/jhqvl3AfyV2/E7hrDUrDwWfntTJDhgxr5ONtetV7jfUhmLFZEgiqx49hf5bGn2EjN43TzZ9Jf8HIzJHAOG8VFcyTHTDYu1wf33wXSdB0oQDHHPw3zWu1iigxIW4e4LjX0sF6ohIWXrb0H40nugCQJ7h4=",
"Connection": "keep-alive",
"Accept-Language": "zh-cn",
"X-AGENT-VERSION": "12.1.1",
"Accept": "application/json;responseformat=3",
"Content-Type": "application/json",
"Accept-Encoding": "br, gzip, deflate",
"X-DEVICE-BRAND": "IOS",
"X-DEVICE-IDENTIFIER": "EA3447D6-1AD9-498F-BE8F-9689815CC66D",
"X-OPERATOR-CODE": "LYNKCO"
},
json = {
"authCode": self.AuthCode,
"redirectUri": "http://www.abcde.com"
}
)
def getCarInfo(self):
"""返回汽车信息"""
if self.CarToken_expires:
now = time.time()
if self.CarToken_expires - now > 60:
json = self.grant_CarInfo()
return json
json = self.getCarToken()
json = self.grant_CarInfo()
return json
json = self.getCarToken()
json = self.grant_CarInfo()
self.EngineStatus = json['data']['vehicleStatus']['basicVehicleStatus']['engineStatus']
return json
def grant_CarInfo(self):
"""获取汽车信息"""
return self.get(
url = "https://api.xchanger.cn/geelyTCAccess/tcservices/vehicle/status/L6T7824Z6JZ047074?latest=Local&target=basic%2Cmore&userId=" + self.UserId,
headers = {
"Host": "api.xchanger.cn",
"X-ENV-TYPE": "production",
"Accept": "application/json;responseformat=3",
"Authorization": self.CarToken,
"Accept-Encoding": "br, gzip, deflate",
"Accept-Language": "zh-cn",
"PLATFORM": "CMA",
"X-APP-ID": "lynkco",
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 8_3 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12F70 Safari/600.1.4",
"X-CLIENT-ID": "APPLE0000APP00IPHONE191Q05659476",
"X-OPERATOR-CODE": "LYNKCO",
"Connection": "keep-alive",
"X-DEVICE-TYPE": "mobile"
}
)
|
|