# !/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