Skip to content

Commit

Permalink
fix: clean up creds inheritance
Browse files Browse the repository at this point in the history
  • Loading branch information
kmaphoenix committed Oct 2, 2024
1 parent ceb1a18 commit 2394e41
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/dfcx_scrapi/tools/dataframe_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import json
import logging
import time
from typing import Dict, List
from typing import Dict, List, Any
import gspread
import pandas as pd
import numpy as np
Expand All @@ -33,7 +33,7 @@
from dfcx_scrapi.core.pages import Pages
from dfcx_scrapi.core.transition_route_groups import TransitionRouteGroups

GLOBAL_SCOPE = [
SHEETS_SCOPE = [
"https://spreadsheets.google.com/feeds",
"https://www.googleapis.com/auth/drive",
]
Expand All @@ -52,8 +52,8 @@ def __init__(
self,
creds_path: str = None,
creds_dict: dict = None,
creds=None,
scope=False,
creds: Any = None,
scope: List[str] = None,
):
super().__init__(
creds_path=creds_path,
Expand All @@ -62,12 +62,7 @@ def __init__(
scope=scope,
)

scopes = GLOBAL_SCOPE

if scope:
scopes += scope

self.creds.scopes.extend(scopes)
self._check_and_update_sheets_scopes()

self.sheets_client = gspread.authorize(self.creds)
self.entities = EntityTypes(creds=self.creds)
Expand Down Expand Up @@ -138,6 +133,11 @@ def _remap_intent_values(original_intent: types.Intent) -> types.Intent:

return new_intent

def _check_and_update_sheets_scopes(self):
"""Update Credentials scopes if possible based on creds type."""
if self.creds.requires_scopes:
self.creds.scopes.extend(SHEETS_SCOPE)

def _update_intent_from_dataframe(
self,
intent_id: str,
Expand Down

0 comments on commit 2394e41

Please sign in to comment.