Skip to content

Commit

Permalink
fix(sso display): correct val passing and add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
lmeyerov authored Oct 12, 2023
1 parent 52c2149 commit 7bfb22e
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions graphistry/pygraphistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ def sso_login(org_name=None, idp_name=None, sso_timeout=SSO_GET_TOKEN_ELAPSE_SEC
:type idp_name: Optional[str]
:param sso_timeout: Set sso login getting token timeout in seconds (blocking mode), set to None if non-blocking mode. Default as SSO_GET_TOKEN_ELAPSE_SECONDS.
:type sso_timeout: Optional[int]
:param opt_into_type: Show the SSO url with display(), webbrowser.open(), or print()
:type opt_into_type: Optional[Literal["display", "browser"]]
:returns: token or auth_url
:rtype: Optional[str]
Expand Down Expand Up @@ -257,6 +259,8 @@ def _handle_auth_url(auth_url, sso_timeout, opt_into_type):
:type auth_url: str
:param sso_timeout: Set sso login getting token timeout in seconds (blocking mode), set to None if non-blocking mode. Default as SSO_GET_TOKEN_ELAPSE_SECONDS.
:type sso_timeout: Optional[int]
:param opt_into_type: Show the SSO url with display(), webbrowser.open(), or print()
:type opt_into_type: Optional[Literal["display", "browser"]]
:returns: token
:rtype: token: Optional[str]
Expand Down Expand Up @@ -568,7 +572,7 @@ def register(
idp_name: Optional[str] = None,
is_sso_login: Optional[bool] = False,
sso_timeout: Optional[int] = SSO_GET_TOKEN_ELAPSE_SECONDS,
sso_opt_into_type: Optional[str] = None
sso_opt_into_type: Optional[Literal["display", "browser"]] = None
):
"""API key registration and server selection
Expand Down Expand Up @@ -612,6 +616,8 @@ def register(
:type idp_name: Optional[str]
:param sso_timeout: Set sso login getting token timeout in seconds (blocking mode), set to None if non-blocking mode. Default as SSO_GET_TOKEN_ELAPSE_SECONDS.
:type sso_timeout: Optional[int]
:param sso_opt_into_type: Show the SSO url with display(), webbrowser.open(), or print()
:type sso_opt_into_type: Optional[Literal["display", "browser"]]
:returns: None.
:rtype: None
Expand All @@ -627,6 +633,14 @@ def register(
import graphistry
graphistry.register(api=3, protocol='http', server='200.1.1.1', org_name="org-name")
**Example: Override SSO url display method to use `display()`, `webbrowser.open()`, or just `print()`**
::
import graphistry
graphistry.register(api=3, protocol='http', server='200.1.1.1', org_name="org-name", sso_opt_into_type="display")
graphistry.register(api=3, protocol='http', server='200.1.1.1', org_name="org-name", sso_opt_into_type="browser")
graphistry.register(api=3, protocol='http', server='200.1.1.1', org_name="org-name", sso_opt_into_type=None)
**Example: Standard (2.0 api by username/password with org_name)**
::
Expand Down Expand Up @@ -696,7 +710,7 @@ def register(
PyGraphistry.api_token(token or PyGraphistry._config['api_token'])
elif not (org_name is None) or is_sso_login:
print(MSG_REGISTER_ENTER_SSO_LOGIN)
PyGraphistry.sso_login(org_name, idp_name, sso_timeout=sso_timeout, sso_opt_into_type=None)
PyGraphistry.sso_login(org_name, idp_name, sso_timeout=sso_timeout, opt_into_type=sso_opt_into_type)

@staticmethod
def __check_login_type_to_reset_token_creds(
Expand Down

0 comments on commit 7bfb22e

Please sign in to comment.