Skip to content

Commit

Permalink
avoid building cd for user commands
Browse files Browse the repository at this point in the history
  • Loading branch information
jay0lee committed Feb 3, 2021
1 parent 141aca9 commit 1b7a43e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/gam/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9757,7 +9757,10 @@ def getUsersToModify(entity_type=None,
entity_type = sys.argv[1].lower()
if entity is None:
entity = sys.argv[2]
cd = buildGAPIObject('directory')
# avoid building cd for user/users since it
# unnnecesarily pushes user through admin auth
if entity_type not in ['user', 'users']:
cd = buildGAPIObject('directory')
if entity_type == 'user':
users = [
entity,
Expand Down

3 comments on commit 1b7a43e

@taers232c
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If GA_DOMAIN isn't set or email addresses are entered without @domain.com, this causes trouble because buildGAPIObject sets GC_Values[GC_DOMAIN].

$ export GA_DOMAIN=rdschool.org
$ gam user testsimple show gmailprofile
Getting Gmail profile for [email protected]
emailAddress,historyId,messagesTotal,threadsTotal
[email protected],22724,10,8
$ unset GA_DOMAIN
$ gam user testsimple show gmailprofile

ERROR: User testsimple@: invalid_request: Invalid impersonation "sub" field.
emailAddress

@jay0lee
Copy link
Member Author

@jay0lee jay0lee commented on 1b7a43e Feb 3, 2021 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@taers232c
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is no @ but GC_Values[GC_DOMAIN] is set then no call is required as the user must have set GA_DOMAIN.

Please sign in to comment.