80 lines
2.8 KiB
Python
80 lines
2.8 KiB
Python
# !/usr/bin/python
|
|
# -*- coding: utf-8 -*-
|
|
from authlib.integrations.requests_client import OAuth2Session
|
|
|
|
|
|
class SignatureYM():
|
|
def __init__(self):
|
|
self.client_id = "95579765e4fe91af9962"
|
|
self.client_secret = "3dcb964ede5d455f1d54623dad5e496bff468f81"
|
|
self.redirect_uri = 'https://auth.yimaogo.com/api/callback'
|
|
self.authorization_base_url = 'https://auth.yimaogo.com/api/login/oauth/authorize'
|
|
self.token_url = 'https://auth.yimaogo.com/api/login/oauth/access_token'
|
|
|
|
def __tokens(self):
|
|
oauth = OAuth2Session(self.client_id, redirect_uri=self.redirect_uri)
|
|
authorization_url, state = oauth.create_authorization_url(self.authorization_base_url)
|
|
token_dict = oauth.fetch_token(self.token_url, authorization_response={}, client_secret=self.client_secret)
|
|
return token_dict["access_token"]
|
|
|
|
def return_headers(self):
|
|
tokens = self.__tokens()
|
|
headers = {
|
|
'Authorization': tokens,
|
|
'User-Agent': 'Apifox/1.0.0 (https://apifox.com)',
|
|
'Content-Type': 'application/json',
|
|
'Accept': '*/*',
|
|
'Host': 'api.test.yimaogo.com',
|
|
'Connection': 'keep-alive'
|
|
}
|
|
return headers
|
|
|
|
class SignatureYM2():
|
|
def __init__(self, Mac= '70:f7:54:07:a6:c0'):
|
|
def __sission_id():
|
|
import random, time
|
|
def generate_24_digit_random_integer():
|
|
timestamp = int(time.time() * 1000)
|
|
random_number = random.randint(0, 99999999999999)
|
|
combined_number = str(timestamp) + str(random_number)
|
|
if len(combined_number) >= 24:
|
|
return int(combined_number[:24])
|
|
else:
|
|
combined_number = combined_number.ljust(24, '0')
|
|
return int(combined_number)
|
|
random_integer = generate_24_digit_random_integer()
|
|
return str(random_integer)
|
|
self.SessionId = __sission_id()
|
|
self.Mac = Mac
|
|
|
|
def _headers(self):
|
|
headers = {
|
|
'SessionId': self.SessionId,
|
|
'Mac': self.Mac,
|
|
'User-Agent': 'Apifox/1.0.0 (https://apifox.com)',
|
|
'Content-Type': 'application/json',
|
|
'Accept': '*/*',
|
|
'Host': 'api.test.yimaogo.com',
|
|
'Connection': 'keep-alive',
|
|
'App_Version': '6.0.9.107',
|
|
'Build_Number': '107',
|
|
}
|
|
return headers
|
|
|
|
class SignatureYM3():
|
|
def __init__(self, GateMac= '74:ee:2a:df:67:4d'):
|
|
self.GateMac = GateMac
|
|
|
|
def _headers(self):
|
|
headers = {
|
|
'GateMac': self.GateMac,
|
|
'User-Agent': 'Apifox/1.0.0 (https://apifox.com)',
|
|
'Content-Type': 'application/json',
|
|
'Accept': '*/*',
|
|
'Host': 'api.test.yimaogo.com',
|
|
'Connection': 'keep-alive'
|
|
}
|
|
return headers
|
|
|
|
|