Skip to content

Commit cf9062e

Browse files
authored
Merge pull request #3703 from webkom/fix-external-sync-google
Fix external sync for google
2 parents 2b0c4fd + fe99fa1 commit cf9062e

File tree

4 files changed

+30
-48
lines changed

4 files changed

+30
-48
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ ENV RELEASE ${RELEASE}
2828

2929
RUN mkdir /app
3030
COPY pyproject.toml /app/pyproject.toml
31+
COPY poetry.lock /app/poetry.lock
3132
WORKDIR /app
3233

3334
RUN pip install poetry

lego/apps/external_sync/utils/gsuite.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
from django.conf import settings
22
from django.core.exceptions import ImproperlyConfigured
33

4+
from google.oauth2 import service_account
45
from googleapiclient.discovery import build
56
from googleapiclient.errors import HttpError
6-
from httplib2 import Http
7-
from oauth2client.service_account import ServiceAccountCredentials
87

98
scopes = [
109
"https://www.googleapis.com/auth/admin.directory.user",
@@ -24,7 +23,7 @@ def __init__(self):
2423
self.client = build(
2524
"admin",
2625
"directory_v1",
27-
http=credentials.authorize(Http()),
26+
credentials=credentials,
2827
cache_discovery=False,
2928
)
3029

@@ -35,10 +34,11 @@ def get_credentials(self):
3534
if settings.GSUITE_CREDENTIALS is None:
3635
raise ImproperlyConfigured("Missing GSuite credentials")
3736

38-
credentials = ServiceAccountCredentials.from_json_keyfile_dict(
39-
settings.GSUITE_CREDENTIALS, scopes
37+
return service_account.Credentials.from_service_account_info(
38+
settings.GSUITE_CREDENTIALS,
39+
scopes=scopes,
40+
subject=settings.GSUITE_DELEGATED_ACCOUNT,
4041
)
41-
return credentials.create_delegated(settings.GSUITE_DELEGATED_ACCOUNT)
4242

4343
def get_user(self, user_key):
4444
return self.client.users().get(userKey=user_key).execute()

poetry.lock

Lines changed: 21 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ beautifulsoup4 = "4.12.2"
2424
bleach = "5.0.1"
2525
requests = "2.32.2"
2626
ldap3 = "2.9.1"
27-
google-api-python-client = "2.96.0"
28-
oauth2client = "4.1.3"
27+
google-api-python-client = "^2.155.0"
28+
google-auth = "^2.37.0"
2929
libthumbor = "2.0.2"
3030
django-health-check = "3.17.0"
3131
djangorestframework = "3.14.0"

0 commit comments

Comments
 (0)