Skip to content

Commit

Permalink
vdk-dag: fix unnecessary authorization failure (#3096)
Browse files Browse the repository at this point in the history
If you have locally configured authorizaton settings (e.g client id,
refresh token and so on) which might be expired or wrong, VDK dag still
tries to authenticate and generate access token even if no
authentication may be required by the Control Service API. This casues
the DAG jobs to fail with authentication error which is unnecssary if
the API didn't require auth.

Instead we now just post a warning about the failure to get acess token.
We fail later if and only if the API requires authentication . If not
everything suceeeds.

Testing Done: local tests pass (they failed before for above reason)

Signed-off-by: Antoni Ivanov <[email protected]>
  • Loading branch information
antoniivanov authored Feb 9, 2024
1 parent 7467786 commit 1402f3a
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,15 @@ def _get_access_token(self) -> str:
if self.auth:
return self.auth.read_access_token()
else:
self._login()
return self.auth.read_access_token()
try:
self._login()
return self.auth.read_access_token()
except Exception as e:
log.warning(
f"Failed to get access token. If authorization is required later it, it won't work."
f"Authentication error is {e}"
)
return None

def _login(self) -> None:
self.auth = Authentication()
Expand Down

0 comments on commit 1402f3a

Please sign in to comment.