コード例 #1
0
ファイル: tableau.py プロジェクト: phoenix-elite1050/airflow
 def _auth_via_token(self) -> Auth.contextmgr:
     tableau_auth = PersonalAccessTokenAuth(
         token_name=self.conn.extra_dejson['token_name'],
         personal_access_token=self.conn.extra_dejson['personal_access_token'],
         site_id=self.site_id,
     )
     return self.server.auth.sign_in_with_personal_access_token(tableau_auth)
コード例 #2
0
    def _authenticate(self):
        # https://tableau.github.io/server-client-python/docs/api-ref#authentication
        authentication = None
        if self.config.username and self.config.password:
            authentication = TableauAuth(
                username=self.config.username,
                password=self.config.password,
                site_id=self.config.site,
            )
        elif self.config.token_name and self.config.token_value:
            authentication = PersonalAccessTokenAuth(self.config.token_name,
                                                     self.config.token_value,
                                                     self.config.site)
        else:
            raise ConfigurationError(
                "Tableau Source: Either username/password or token_name/token_value must be set"
            )

        try:
            self.server = Server(self.config.connect_uri,
                                 use_server_version=True)
            self.server.auth.sign_in(authentication)
        except ServerResponseError as e:
            logger.error(e)
            self.report.report_failure(
                key="tableau-login",
                reason=f"Unable to Login with credentials provided"
                f"Reason: {str(e)}",
            )
        except Exception as e:
            logger.error(e)
            self.report.report_failure(key="tableau-login",
                                       reason=f"Unable to Login"
                                       f"Reason: {str(e)}")
コード例 #3
0
ファイル: tableau.py プロジェクト: leahecole/airflow
 def _auth_via_token(self) -> Auth.contextmgr:
     """The method is deprecated. Please, use the authentication via password instead."""
     warnings.warn(
         "Authentication via personal access token is deprecated. "
         "Please, use the password authentication to avoid inconsistencies.",
         DeprecationWarning,
     )
     tableau_auth = PersonalAccessTokenAuth(
         token_name=self.conn.extra_dejson['token_name'],
         personal_access_token=self.conn.
         extra_dejson['personal_access_token'],
         site_id=self.site_id,
     )
     return self.server.auth.sign_in_with_personal_access_token(
         tableau_auth)