creación de scheduler.json para ejecución de servicio
This commit is contained in:
1 parent
839aad698d
commit
1c39f6f45f
11 files changed
+112
-400
No files matched your search
+9
-7
@@ -8,6 +8,7 @@ from dotenv import load_dotenv
|
||||
import requests
|
||||
import urllib3
|
||||
|
||||
# ============================================================================
|
||||
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||||
|
||||
load_dotenv()
|
||||
@@ -21,11 +22,11 @@ USER = os.getenv("SUNAT_USER", "").strip()
|
||||
PASSWORD = os.getenv("SUNAT_PASSWORD", "").strip()
|
||||
J_USERNAME = USER
|
||||
|
||||
|
||||
# ============================================================================
|
||||
def log(msg):
|
||||
print(f" {msg}")
|
||||
|
||||
|
||||
# ============================================================================
|
||||
def decode_jwt(token):
|
||||
try:
|
||||
payload_b64 = token.split(".")[1]
|
||||
@@ -36,7 +37,7 @@ def decode_jwt(token):
|
||||
except:
|
||||
return None
|
||||
|
||||
|
||||
# ============================================================================
|
||||
def save_token(token):
|
||||
payload = decode_jwt(token) or {}
|
||||
expires_at = payload.get("exp", 0)
|
||||
@@ -56,7 +57,7 @@ def save_token(token):
|
||||
print(f" Usuario SOL: {data['usuario_sol']}")
|
||||
return True
|
||||
|
||||
|
||||
# ============================================================================
|
||||
def try_password_grant():
|
||||
print("\n🔑 Intentando grant_type=password...")
|
||||
data = {
|
||||
@@ -88,7 +89,7 @@ def try_password_grant():
|
||||
print(f" ❌ Error: {e}")
|
||||
return False
|
||||
|
||||
|
||||
# ============================================================================
|
||||
def try_auth_code_flow():
|
||||
print("\n🔑 Intentando flujo authorization_code...")
|
||||
log("1. Accediendo a MenuInternet.htm para obtener redirect...")
|
||||
@@ -275,7 +276,7 @@ def try_auth_code_flow():
|
||||
|
||||
return False
|
||||
|
||||
|
||||
# ============================================================================
|
||||
def main():
|
||||
print("=" * 60)
|
||||
print("🔐 LOGIN SUNAT API (sin Playwright)")
|
||||
@@ -302,6 +303,7 @@ def main():
|
||||
print(" - Cambios en el flujo OAuth2 de SUNAT")
|
||||
print("\n Usa get_token.py como respaldo: python get_token.py")
|
||||
|
||||
|
||||
# ============================================================================
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
# ============================================================================
|
||||
Reference in new issue
Block a user