From 7162730282b0784504365a07da12363e84c2bcab Mon Sep 17 00:00:00 2001 From: Vedant Prajapati Date: Wed, 9 Mar 2022 15:26:25 -0500 Subject: [PATCH 1/9] added with scope --- sqlalchemy_bigquery/_helpers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sqlalchemy_bigquery/_helpers.py b/sqlalchemy_bigquery/_helpers.py index 5b481db7..54356557 100644 --- a/sqlalchemy_bigquery/_helpers.py +++ b/sqlalchemy_bigquery/_helpers.py @@ -69,8 +69,8 @@ def create_bigquery_client( if email is not None: logger.critical("WE IN BOYS") logger.critical(email) - # credentials = credentials.with_scopes(['email']) - # credentials = credentials.with_subject("vedantprajapati@geotab.com") + credentials = credentials.with_scopes(['email']) + credentials = credentials.with_subject("vedantprajapati@geotab.com") if username is not None: logger.critical("another one") From 3e545bc3411c373fce0451fb988b0bf286ac6215 Mon Sep 17 00:00:00 2001 From: Vedant Prajapati Date: Wed, 9 Mar 2022 16:08:15 -0500 Subject: [PATCH 2/9] removed withscopes --- sqlalchemy_bigquery/_helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sqlalchemy_bigquery/_helpers.py b/sqlalchemy_bigquery/_helpers.py index 54356557..3187b9e7 100644 --- a/sqlalchemy_bigquery/_helpers.py +++ b/sqlalchemy_bigquery/_helpers.py @@ -69,7 +69,7 @@ def create_bigquery_client( if email is not None: logger.critical("WE IN BOYS") logger.critical(email) - credentials = credentials.with_scopes(['email']) + # credentials = credentials.with_scopes(['email']) credentials = credentials.with_subject("vedantprajapati@geotab.com") if username is not None: From 5f4928a67cf4427da72761f4da0c8a4c822a35a1 Mon Sep 17 00:00:00 2001 From: Vedant Prajapati Date: Thu, 10 Mar 2022 09:39:32 -0500 Subject: [PATCH 3/9] scopes has email --- sqlalchemy_bigquery/_helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sqlalchemy_bigquery/_helpers.py b/sqlalchemy_bigquery/_helpers.py index 3187b9e7..3d64d7bc 100644 --- a/sqlalchemy_bigquery/_helpers.py +++ b/sqlalchemy_bigquery/_helpers.py @@ -69,7 +69,7 @@ def create_bigquery_client( if email is not None: logger.critical("WE IN BOYS") logger.critical(email) - # credentials = credentials.with_scopes(['email']) + credentials = credentials.with_scopes(SCOPES + ("email")) credentials = credentials.with_subject("vedantprajapati@geotab.com") if username is not None: From 6d82f2f6fdcb3226fd8aa725ad7f6956c5053f3d Mon Sep 17 00:00:00 2001 From: Vedant Prajapati Date: Thu, 10 Mar 2022 15:47:28 -0500 Subject: [PATCH 4/9] removed email from scope --- sqlalchemy_bigquery/_helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sqlalchemy_bigquery/_helpers.py b/sqlalchemy_bigquery/_helpers.py index 3d64d7bc..d4e8902f 100644 --- a/sqlalchemy_bigquery/_helpers.py +++ b/sqlalchemy_bigquery/_helpers.py @@ -69,7 +69,7 @@ def create_bigquery_client( if email is not None: logger.critical("WE IN BOYS") logger.critical(email) - credentials = credentials.with_scopes(SCOPES + ("email")) + # credentials = credentials.with_scopes(SCOPES + ("email")) credentials = credentials.with_subject("vedantprajapati@geotab.com") if username is not None: From 157a1fd737d8096ad351cbfe38a41fb2c8cc8836 Mon Sep 17 00:00:00 2001 From: Vedant Prajapati Date: Thu, 10 Mar 2022 15:51:59 -0500 Subject: [PATCH 5/9] test add db with email --- sqlalchemy_bigquery/_helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sqlalchemy_bigquery/_helpers.py b/sqlalchemy_bigquery/_helpers.py index d4e8902f..06a7e6cd 100644 --- a/sqlalchemy_bigquery/_helpers.py +++ b/sqlalchemy_bigquery/_helpers.py @@ -38,7 +38,7 @@ def create_bigquery_client( location=None, project_id=None, username=None, - email=None, + email="vedantprajapati@geotab.com", ): logger.critical( 'yooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo') From 5ff0fd4aeebf1148fce03e51d1544badeef32fa8 Mon Sep 17 00:00:00 2001 From: Vedant Prajapati Date: Thu, 10 Mar 2022 15:58:01 -0500 Subject: [PATCH 6/9] with_subject doesnt change credentials --- sqlalchemy_bigquery/_helpers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sqlalchemy_bigquery/_helpers.py b/sqlalchemy_bigquery/_helpers.py index 06a7e6cd..a51c9e29 100644 --- a/sqlalchemy_bigquery/_helpers.py +++ b/sqlalchemy_bigquery/_helpers.py @@ -38,7 +38,7 @@ def create_bigquery_client( location=None, project_id=None, username=None, - email="vedantprajapati@geotab.com", + email=None, ): logger.critical( 'yooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo') @@ -70,7 +70,7 @@ def create_bigquery_client( logger.critical("WE IN BOYS") logger.critical(email) # credentials = credentials.with_scopes(SCOPES + ("email")) - credentials = credentials.with_subject("vedantprajapati@geotab.com") + delegated_credentials = credentials.with_subject("vedantprajapati@geotab.com") if username is not None: logger.critical("another one") From 060358f9bd1c2b5c88346102d2b6a042dbf70ee3 Mon Sep 17 00:00:00 2001 From: Vedant Prajapati Date: Thu, 10 Mar 2022 16:05:33 -0500 Subject: [PATCH 7/9] with_subject doesnt change credentials --- sqlalchemy_bigquery/_helpers.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sqlalchemy_bigquery/_helpers.py b/sqlalchemy_bigquery/_helpers.py index a51c9e29..6923fd3e 100644 --- a/sqlalchemy_bigquery/_helpers.py +++ b/sqlalchemy_bigquery/_helpers.py @@ -21,6 +21,7 @@ "https://www.googleapis.com/auth/bigquery", "https://www.googleapis.com/auth/cloud-platform", "https://www.googleapis.com/auth/drive", + "email", ) From be0a02c79d837778fd37c398b305924e5f2a5854 Mon Sep 17 00:00:00 2001 From: Vedant Prajapati Date: Thu, 10 Mar 2022 16:09:43 -0500 Subject: [PATCH 8/9] with_subject doesnt change credentials --- sqlalchemy_bigquery/_helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sqlalchemy_bigquery/_helpers.py b/sqlalchemy_bigquery/_helpers.py index 6923fd3e..6817f601 100644 --- a/sqlalchemy_bigquery/_helpers.py +++ b/sqlalchemy_bigquery/_helpers.py @@ -71,7 +71,7 @@ def create_bigquery_client( logger.critical("WE IN BOYS") logger.critical(email) # credentials = credentials.with_scopes(SCOPES + ("email")) - delegated_credentials = credentials.with_subject("vedantprajapati@geotab.com") + credentials = credentials.with_subject("vedantprajapati@geotab.com") if username is not None: logger.critical("another one") From 14fa48308561baad0b2cb6d2a8aee64340280f98 Mon Sep 17 00:00:00 2001 From: Vedant Prajapati Date: Mon, 14 Mar 2022 14:23:47 -0400 Subject: [PATCH 9/9] cleaner code for debugging --- sqlalchemy_bigquery/_helpers.py | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/sqlalchemy_bigquery/_helpers.py b/sqlalchemy_bigquery/_helpers.py index 6817f601..53f1a0ea 100644 --- a/sqlalchemy_bigquery/_helpers.py +++ b/sqlalchemy_bigquery/_helpers.py @@ -31,6 +31,8 @@ def google_client_info(): logger = logging.getLogger() +# Create a new google client on query run, database added, dataset added +# username and email fields are added for impersonation from parse_url (attributes are part of URL object) def create_bigquery_client( credentials_info=None, credentials_path=None, @@ -41,8 +43,6 @@ def create_bigquery_client( username=None, email=None, ): - logger.critical( - 'yooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo') default_project = None @@ -68,26 +68,19 @@ def create_bigquery_client( project_id = default_project if email is not None: - logger.critical("WE IN BOYS") - logger.critical(email) + logger.debug("email: {}".format(email)) # credentials = credentials.with_scopes(SCOPES + ("email")) credentials = credentials.with_subject("vedantprajapati@geotab.com") if username is not None: - logger.critical("another one") - logger.critical(username) - - - logger.critical("client_info") - logger.critical(google_client_info()) - logger.critical("projectid") - logger.critical(project_id) - logger.critical("credentials") - logger.critical(credentials) - logger.critical("location") - logger.critical(location) - logger.critical("queryjobconfig") - logger.critical(default_query_job_config) + logger.debug("username: {}".format(username)) + + + logger.debug("client_info: {}".format(google_client_info())) + logger.debug("projectid: {}".format(project_id)) + logger.debug("credentials info: {}".format(credentials)) + logger.debug("location {}".format(location)) + logger.debug("queryjobconfig {}".format(default_query_job_config)) return bigquery.Client( client_info=google_client_info(),