Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor: microstrategy patch login mode #18827

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 23 additions & 19 deletions ingestion/src/metadata/ingestion/source/dashboard/mstr/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
logger = ingestion_logger()

API_VERSION = "MicroStrategyLibrary/api"
LOGIN_MODE_GUEST = 8
LOGIN_MODE_GUEST = 1
APPLICATION_TYPE = 35


Expand Down Expand Up @@ -77,27 +77,31 @@ def _get_auth_header_and_cookies(self) -> Optional[AuthHeaderCookie]:
To know about the data params below please visit
https://demo.microstrategy.com/MicroStrategyLibrary/api-docs/index.html#/Authentication/postLogin
"""
try:
data = {
"username": self.config.username,
"password": self.config.password.get_secret_value(),
"loginMode": LOGIN_MODE_GUEST,
"applicationType": APPLICATION_TYPE,
}
data = {
"username": self.config.username,
"password": self.config.password.get_secret_value(),
"loginMode": LOGIN_MODE_GUEST,
"applicationType": APPLICATION_TYPE,
}
response = requests.post(
url=self._get_base_url("auth/login"), data=data, timeout=60
)
if not response.status_code == 204:
logger.error(
f"Auth Failed with login mode: {LOGIN_MODE_GUEST}, Error: {response.text}"
)
logger.error("Trying with login mode: 8")
data["loginMode"] = 8
response = requests.post(
url=self._get_base_url("auth/login"), data=data, timeout=60
)
if not response:
raise SourceConnectionException()
return AuthHeaderCookie(
auth_header=response.headers, auth_cookies=response.cookies
)
except Exception as exc:
logger.debug(traceback.format_exc())
logger.error(
f"Failed to fetch the auth header and cookies due to [{exc}], please validate credentials"
)
return None
if not response.status_code == 204:
raise SourceConnectionException(
f"Auth Failed with login mode: 8 and {LOGIN_MODE_GUEST}, Error: {response.text}"
)
return AuthHeaderCookie(
auth_header=response.headers, auth_cookies=response.cookies
)

def _set_api_session(self) -> bool:
"""
Expand Down
Loading