From 8e57b165a6a3d770ef5f4ca2d27164c3e7e0726e Mon Sep 17 00:00:00 2001 From: Ayush Shah Date: Thu, 1 Jun 2023 09:40:18 +0530 Subject: [PATCH] Fix LineTooLong (#11833) * Fix LineTooLong * Add Timeout ( fix lint ) --- .../src/metadata/ingestion/ometa/auth_provider.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ingestion/src/metadata/ingestion/ometa/auth_provider.py b/ingestion/src/metadata/ingestion/ometa/auth_provider.py index bc0984b3dac..4b4afe52082 100644 --- a/ingestion/src/metadata/ingestion/ometa/auth_provider.py +++ b/ingestion/src/metadata/ingestion/ometa/auth_provider.py @@ -11,7 +11,6 @@ """ Interface definition for an Auth provider """ -import http.client import json import os.path import sys @@ -298,17 +297,20 @@ class Auth0AuthenticationProvider(AuthenticationProvider): return cls(config) def auth_token(self) -> None: - conn = http.client.HTTPSConnection(self.security_config.domain) + payload = ( f"grant_type=client_credentials&client_id={self.security_config.clientId}" f"&client_secret={self.security_config.secretKey.get_secret_value()}" f"&audience=https://{self.security_config.domain}/api/v2/" ) headers = {"content-type": "application/x-www-form-urlencoded"} - conn.request( - "POST", f"/{self.security_config.domain}/oauth/token", payload, headers + res = requests.post( + url=f"https://{self.security_config.domain}/oauth/token", + data=payload, + headers=headers, + timeout=60 * 5, ) - res = conn.getresponse() + data = json.loads(res.read().decode("utf-8")) token = data.get(ACCESS_TOKEN)