mirror of
https://github.com/GAM-team/GAM.git
synced 2026-07-04 04:41:35 +00:00
Added option usertokencounts to gam <UserTypeEntity> print|show tokens
This commit is contained in:
@@ -10,10 +10,15 @@ Add the `-s` option to the end of the above commands to suppress creating the `g
|
|||||||
|
|
||||||
See [Downloads](https://github.com/taers232c/GAMADV-XTD3/wiki/Downloads) for Windows or other options, including manual installation
|
See [Downloads](https://github.com/taers232c/GAMADV-XTD3/wiki/Downloads) for Windows or other options, including manual installation
|
||||||
|
|
||||||
|
### 6.77.09
|
||||||
|
|
||||||
|
Added option `usertokencounts` to `gam <UserTypeEntity> print|show tokens` that causes GAM to display
|
||||||
|
each user and their number of access tokens; there are no details.
|
||||||
|
|
||||||
### 6.77.08
|
### 6.77.08
|
||||||
|
|
||||||
Fixed bugs in `gam <UserTypeEntity> delete chatmember <ChatSpace> ... group <GroupItem>`
|
Fixed bugs in `gam <UserTypeEntity> delete chatmember <ChatSpace> ... group <GroupItem>`
|
||||||
and `gam <UserTypeEntity> delete chatmember <ChatSpace> ... groups <GroupEntity>` that caused an error.
|
and `gam <UserTypeEntity> sync chatmember <ChatSpace> ... groups <GroupEntity>` that caused an error.
|
||||||
|
|
||||||
### 6.77.07
|
### 6.77.07
|
||||||
|
|
||||||
|
|||||||
@@ -335,7 +335,7 @@ writes the credentials into the file oauth2.txt.
|
|||||||
admin@server:/Users/admin/bin/gamadv-xtd3$ rm -f /Users/admin/GAMConfig/oauth2.txt
|
admin@server:/Users/admin/bin/gamadv-xtd3$ rm -f /Users/admin/GAMConfig/oauth2.txt
|
||||||
admin@server:/Users/admin/bin/gamadv-xtd3$ ./gam version
|
admin@server:/Users/admin/bin/gamadv-xtd3$ ./gam version
|
||||||
WARNING: Config File: /Users/admin/GAMConfig/gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: /Users/admin/GAMConfig/oauth2.txt, Not Found
|
WARNING: Config File: /Users/admin/GAMConfig/gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: /Users/admin/GAMConfig/oauth2.txt, Not Found
|
||||||
GAMADV-XTD3 6.77.08 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
|
GAMADV-XTD3 6.77.09 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
|
||||||
Ross Scroggs <ross.scroggs@gmail.com>
|
Ross Scroggs <ross.scroggs@gmail.com>
|
||||||
Python 3.12.4 64-bit final
|
Python 3.12.4 64-bit final
|
||||||
MacOS Sonoma 14.5 x86_64
|
MacOS Sonoma 14.5 x86_64
|
||||||
@@ -1009,7 +1009,7 @@ writes the credentials into the file oauth2.txt.
|
|||||||
C:\GAMADV-XTD3>del C:\GAMConfig\oauth2.txt
|
C:\GAMADV-XTD3>del C:\GAMConfig\oauth2.txt
|
||||||
C:\GAMADV-XTD3>gam version
|
C:\GAMADV-XTD3>gam version
|
||||||
WARNING: Config File: C:\GAMConfig\gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: C:\GAMConfig\oauth2.txt, Not Found
|
WARNING: Config File: C:\GAMConfig\gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: C:\GAMConfig\oauth2.txt, Not Found
|
||||||
GAMADV-XTD3 6.77.08 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
|
GAMADV-XTD3 6.77.09 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
|
||||||
Ross Scroggs <ross.scroggs@gmail.com>
|
Ross Scroggs <ross.scroggs@gmail.com>
|
||||||
Python 3.12.4 64-bit final
|
Python 3.12.4 64-bit final
|
||||||
Windows-10-10.0.17134 AMD64
|
Windows-10-10.0.17134 AMD64
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
- [Definitions](#definitions)
|
- [Definitions](#definitions)
|
||||||
- [Delete a user's token](#delete-a-users-token)
|
- [Delete a user's token](#delete-a-users-token)
|
||||||
- [Display individual user's tokens](#display-individual-users-tokens)
|
- [Display individual user's tokens](#display-individual-users-tokens)
|
||||||
|
- [Display individual user's token counts](#display-individual-users-token-counts)
|
||||||
- [Display aggregated user's tokens](#display-aggregated-users-tokens)
|
- [Display aggregated user's tokens](#display-aggregated-users-tokens)
|
||||||
|
|
||||||
## API documentation
|
## API documentation
|
||||||
@@ -27,6 +28,9 @@ gam <UserTypeEntity> show tokens|token|3lo|oauth [clientid <ClientID>]
|
|||||||
gam print tokens|token [todrive <ToDriveAttributes>*] [clientid <ClientID>]
|
gam print tokens|token [todrive <ToDriveAttributes>*] [clientid <ClientID>]
|
||||||
[orderby clientid|id|appname|displaytext] [delimiter <Character>]
|
[orderby clientid|id|appname|displaytext] [delimiter <Character>]
|
||||||
[<UserTypeEntity>]
|
[<UserTypeEntity>]
|
||||||
|
gam show tokens|token [clientid <ClientID>]
|
||||||
|
[orderby clientid|id|appname|displaytext] [delimiter <Character>]
|
||||||
|
[<UserTypeEntity>]
|
||||||
```
|
```
|
||||||
By default, all client tokens for a user are displayed, use `clientid <ClientID>` to display a specific client token.
|
By default, all client tokens for a user are displayed, use `clientid <ClientID>` to display a specific client token.
|
||||||
|
|
||||||
@@ -43,6 +47,26 @@ This example shows which domain users have the Google Apps Sync for Microsoft Ou
|
|||||||
gam all users print token clientid 1095133494869.apps.googleusercontent.com
|
gam all users print token clientid 1095133494869.apps.googleusercontent.com
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Display individual user's token counts
|
||||||
|
```
|
||||||
|
gam <UserTypeEntity> print tokens|token [todrive <ToDriveAttributes>*] [clientid <ClientID>]
|
||||||
|
usertokencounts
|
||||||
|
gam <UserTypeEntity> show tokens|token|3lo|oauth [clientid <ClientID>]
|
||||||
|
usertokencounts
|
||||||
|
gam print tokens|token [todrive <ToDriveAttributes>*] [clientid <ClientID>]
|
||||||
|
usertokencounts
|
||||||
|
[<UserTypeEntity>]
|
||||||
|
gam show tokens|token [clientid <ClientID>]
|
||||||
|
usertokencounts
|
||||||
|
[<UserTypeEntity>]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Example
|
||||||
|
This example shows which domain users have any access tokens.
|
||||||
|
```
|
||||||
|
gam config csv_output_row_filter "tokenCount:count>0" all users print tokens usertokencounts
|
||||||
|
```
|
||||||
|
|
||||||
## Display aggregated user's tokens
|
## Display aggregated user's tokens
|
||||||
```
|
```
|
||||||
gam <UserTypeEntity> print tokens|token [todrive <ToDriveAttributes>*] [clientid <ClientID>]
|
gam <UserTypeEntity> print tokens|token [todrive <ToDriveAttributes>*] [clientid <ClientID>]
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
Print the current version of Gam with details
|
Print the current version of Gam with details
|
||||||
```
|
```
|
||||||
gam version
|
gam version
|
||||||
GAMADV-XTD3 6.77.08 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
|
GAMADV-XTD3 6.77.09 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
|
||||||
Ross Scroggs <ross.scroggs@gmail.com>
|
Ross Scroggs <ross.scroggs@gmail.com>
|
||||||
Python 3.12.4 64-bit final
|
Python 3.12.4 64-bit final
|
||||||
MacOS Sonoma 14.5 x86_64
|
MacOS Sonoma 14.5 x86_64
|
||||||
@@ -15,7 +15,7 @@ Time: 2023-06-02T21:10:00-07:00
|
|||||||
Print the current version of Gam with details and time offset information
|
Print the current version of Gam with details and time offset information
|
||||||
```
|
```
|
||||||
gam version timeoffset
|
gam version timeoffset
|
||||||
GAMADV-XTD3 6.77.08 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
|
GAMADV-XTD3 6.77.09 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
|
||||||
Ross Scroggs <ross.scroggs@gmail.com>
|
Ross Scroggs <ross.scroggs@gmail.com>
|
||||||
Python 3.12.4 64-bit final
|
Python 3.12.4 64-bit final
|
||||||
MacOS Sonoma 14.5 x86_64
|
MacOS Sonoma 14.5 x86_64
|
||||||
@@ -27,7 +27,7 @@ Your system time differs from www.googleapis.com by less than 1 second
|
|||||||
Print the current version of Gam with extended details and SSL information
|
Print the current version of Gam with extended details and SSL information
|
||||||
```
|
```
|
||||||
gam version extended
|
gam version extended
|
||||||
GAMADV-XTD3 6.77.08 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
|
GAMADV-XTD3 6.77.09 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
|
||||||
Ross Scroggs <ross.scroggs@gmail.com>
|
Ross Scroggs <ross.scroggs@gmail.com>
|
||||||
Python 3.12.4 64-bit final
|
Python 3.12.4 64-bit final
|
||||||
MacOS Sonoma 14.5 x86_64
|
MacOS Sonoma 14.5 x86_64
|
||||||
@@ -64,7 +64,7 @@ MacOS High Sierra 10.13.6 x86_64
|
|||||||
Path: /Users/Admin/bin/gamadv-xtd3
|
Path: /Users/Admin/bin/gamadv-xtd3
|
||||||
Version Check:
|
Version Check:
|
||||||
Current: 5.35.08
|
Current: 5.35.08
|
||||||
Latest: 6.77.08
|
Latest: 6.77.09
|
||||||
echo $?
|
echo $?
|
||||||
1
|
1
|
||||||
```
|
```
|
||||||
@@ -72,7 +72,7 @@ echo $?
|
|||||||
Print the current version number without details
|
Print the current version number without details
|
||||||
```
|
```
|
||||||
gam version simple
|
gam version simple
|
||||||
6.77.08
|
6.77.09
|
||||||
```
|
```
|
||||||
In Linux/MacOS you can do:
|
In Linux/MacOS you can do:
|
||||||
```
|
```
|
||||||
@@ -82,7 +82,7 @@ echo $VER
|
|||||||
Print the current version of Gam and address of this Wiki
|
Print the current version of Gam and address of this Wiki
|
||||||
```
|
```
|
||||||
gam help
|
gam help
|
||||||
GAM 6.77.08 - https://github.com/taers232c/GAMADV-XTD3
|
GAM 6.77.09 - https://github.com/taers232c/GAMADV-XTD3
|
||||||
Ross Scroggs <ross.scroggs@gmail.com>
|
Ross Scroggs <ross.scroggs@gmail.com>
|
||||||
Python 3.12.4 64-bit final
|
Python 3.12.4 64-bit final
|
||||||
MacOS Sonoma 14.5 x86_64
|
MacOS Sonoma 14.5 x86_64
|
||||||
|
|||||||
@@ -8181,11 +8181,18 @@ gam <UserTypeEntity> show sheetrange <DriveFileEntity>
|
|||||||
gam <UserTypeEntity> delete tokens clientid <ClientID>
|
gam <UserTypeEntity> delete tokens clientid <ClientID>
|
||||||
|
|
||||||
gam <UserTypeEntity> print tokens|token [todrive <ToDriveAttribute>*] [clientid <ClientID>]
|
gam <UserTypeEntity> print tokens|token [todrive <ToDriveAttribute>*] [clientid <ClientID>]
|
||||||
[aggregateby|orderby clientid|id|appname|displaytext] [delimiter <Character>]
|
[usertokencounts|(aggregateusersby|orderby clientid|id|appname|displaytext)]
|
||||||
|
[delimiter <Character>]
|
||||||
gam <UserTypeEntity> show tokens|token|3lo|oauth [clientid <ClientID>]
|
gam <UserTypeEntity> show tokens|token|3lo|oauth [clientid <ClientID>]
|
||||||
[aggregateby|orderby clientid|id|appname|displaytext]
|
[usertokencounts|(aggregateusersby|orderby clientid|id|appname|displaytext)]
|
||||||
|
[delimiter <Character>]
|
||||||
gam print tokens|token [todrive <ToDriveAttribute>*] [clientid <ClientID>]
|
gam print tokens|token [todrive <ToDriveAttribute>*] [clientid <ClientID>]
|
||||||
[aggregateby|orderby clientid|id|appname|displaytext] [delimiter <Character>]
|
[usertokencounts|(aggregateusersby|orderby clientid|id|appname|displaytext)]
|
||||||
|
[delimiter <Character>]
|
||||||
|
[<UserTypeEntity>]
|
||||||
|
gam show tokens|token [clientid <ClientID>]
|
||||||
|
[usertokencounts|(aggregateusersby|orderby clientid|id|appname|displaytext)]
|
||||||
|
[delimiter <Character>]
|
||||||
[<UserTypeEntity>]
|
[<UserTypeEntity>]
|
||||||
|
|
||||||
# Users - YouTube
|
# Users - YouTube
|
||||||
|
|||||||
@@ -2,10 +2,15 @@
|
|||||||
|
|
||||||
Merged GAM-Team version
|
Merged GAM-Team version
|
||||||
|
|
||||||
|
6.77.09
|
||||||
|
|
||||||
|
Added option `usertokencounts` to `gam <UserTypeEntity> print|show tokens` that causes GAM to display
|
||||||
|
each user and their number of access tokens; there are no details.
|
||||||
|
|
||||||
6.77.08
|
6.77.08
|
||||||
|
|
||||||
Fixed bugs in `gam <UserTypeEntity> delete chatmember <ChatSpace> ... group <GroupItem>`
|
Fixed bugs in `gam <UserTypeEntity> delete chatmember <ChatSpace> ... group <GroupItem>`
|
||||||
and `gam <UserTypeEntity> delete chatmember <ChatSpace> ... groups <GroupEntity>` that caused an error.
|
and `gam <UserTypeEntity> sync chatmember <ChatSpace> ... groups <GroupEntity>` that caused an error.
|
||||||
|
|
||||||
6.77.07
|
6.77.07
|
||||||
|
|
||||||
|
|||||||
@@ -66434,7 +66434,7 @@ def deleteTokens(users):
|
|||||||
|
|
||||||
TOKENS_FIELDS_TITLES = ['clientId', 'displayText', 'anonymous', 'nativeApp', 'userKey', 'scopes']
|
TOKENS_FIELDS_TITLES = ['clientId', 'displayText', 'anonymous', 'nativeApp', 'userKey', 'scopes']
|
||||||
TOKENS_AGGREGATE_FIELDS_TITLES = ['clientId', 'displayText', 'anonymous', 'nativeApp', 'users', 'scopes']
|
TOKENS_AGGREGATE_FIELDS_TITLES = ['clientId', 'displayText', 'anonymous', 'nativeApp', 'users', 'scopes']
|
||||||
TOKENS_ORDERBY_CHOICE_MAP = {
|
TOKENS_AGGREGATE_ORDERBY_CHOICE_MAP = {
|
||||||
'clientid': 'clientId',
|
'clientid': 'clientId',
|
||||||
'id': 'clientId',
|
'id': 'clientId',
|
||||||
'displaytext': 'displayText',
|
'displaytext': 'displayText',
|
||||||
@@ -66443,6 +66443,7 @@ TOKENS_ORDERBY_CHOICE_MAP = {
|
|||||||
TOKENS_TITLE_MAP = {
|
TOKENS_TITLE_MAP = {
|
||||||
'clientId': 'Client ID',
|
'clientId': 'Client ID',
|
||||||
'displayText': 'App Name',
|
'displayText': 'App Name',
|
||||||
|
'user': 'user',
|
||||||
}
|
}
|
||||||
|
|
||||||
def _printShowTokens(entityType, users):
|
def _printShowTokens(entityType, users):
|
||||||
@@ -66484,11 +66485,13 @@ def _printShowTokens(entityType, users):
|
|||||||
elif myarg == 'clientid':
|
elif myarg == 'clientid':
|
||||||
clientId = commonClientIds(getString(Cmd.OB_CLIENT_ID))
|
clientId = commonClientIds(getString(Cmd.OB_CLIENT_ID))
|
||||||
elif myarg == 'orderby':
|
elif myarg == 'orderby':
|
||||||
orderBy = getChoice(TOKENS_ORDERBY_CHOICE_MAP, mapChoice=True)
|
orderBy = getChoice(TOKENS_AGGREGATE_ORDERBY_CHOICE_MAP, mapChoice=True)
|
||||||
elif myarg == 'aggregateusersby':
|
elif myarg == 'aggregateusersby':
|
||||||
aggregateUsersBy = getChoice(TOKENS_ORDERBY_CHOICE_MAP, mapChoice=True)
|
aggregateUsersBy = getChoice(TOKENS_AGGREGATE_ORDERBY_CHOICE_MAP, mapChoice=True)
|
||||||
if aggregateUsersBy == 'displayText':
|
if aggregateUsersBy == 'displayText':
|
||||||
tokenNameIdMap = {}
|
tokenNameIdMap = {}
|
||||||
|
elif myarg == 'usertokencounts':
|
||||||
|
aggregateUsersBy = 'user'
|
||||||
elif myarg == 'delimiter':
|
elif myarg == 'delimiter':
|
||||||
delimiter = getCharacter()
|
delimiter = getCharacter()
|
||||||
elif not entityType:
|
elif not entityType:
|
||||||
@@ -66501,8 +66504,10 @@ def _printShowTokens(entityType, users):
|
|||||||
if csvPF:
|
if csvPF:
|
||||||
if not aggregateUsersBy:
|
if not aggregateUsersBy:
|
||||||
csvPF.SetTitles(['user']+TOKENS_FIELDS_TITLES)
|
csvPF.SetTitles(['user']+TOKENS_FIELDS_TITLES)
|
||||||
else:
|
elif aggregateUsersBy != 'user':
|
||||||
csvPF.SetTitles(TOKENS_AGGREGATE_FIELDS_TITLES)
|
csvPF.SetTitles(TOKENS_AGGREGATE_FIELDS_TITLES)
|
||||||
|
else:
|
||||||
|
csvPF.SetTitles(['user', 'tokenCount'])
|
||||||
else:
|
else:
|
||||||
if not aggregateUsersBy:
|
if not aggregateUsersBy:
|
||||||
tokenTitle = TOKENS_TITLE_MAP[orderBy]
|
tokenTitle = TOKENS_TITLE_MAP[orderBy]
|
||||||
@@ -66527,8 +66532,8 @@ def _printShowTokens(entityType, users):
|
|||||||
throwReasons=[GAPI.USER_NOT_FOUND, GAPI.DOMAIN_NOT_FOUND,
|
throwReasons=[GAPI.USER_NOT_FOUND, GAPI.DOMAIN_NOT_FOUND,
|
||||||
GAPI.DOMAIN_CANNOT_USE_APIS, GAPI.FORBIDDEN, GAPI.BAD_REQUEST],
|
GAPI.DOMAIN_CANNOT_USE_APIS, GAPI.FORBIDDEN, GAPI.BAD_REQUEST],
|
||||||
userKey=user, fields=f'items({fields})')
|
userKey=user, fields=f'items({fields})')
|
||||||
|
jcount = len(results)
|
||||||
if not aggregateUsersBy:
|
if not aggregateUsersBy:
|
||||||
jcount = len(results)
|
|
||||||
if not csvPF:
|
if not csvPF:
|
||||||
entityPerformActionNumItems([Ent.USER, user], jcount, Ent.ACCESS_TOKEN, i, count)
|
entityPerformActionNumItems([Ent.USER, user], jcount, Ent.ACCESS_TOKEN, i, count)
|
||||||
Ind.Increment()
|
Ind.Increment()
|
||||||
@@ -66547,7 +66552,7 @@ def _printShowTokens(entityType, users):
|
|||||||
csvPF.WriteRow(row)
|
csvPF.WriteRow(row)
|
||||||
elif GC.Values[GC.CSV_OUTPUT_USERS_AUDIT]:
|
elif GC.Values[GC.CSV_OUTPUT_USERS_AUDIT]:
|
||||||
csvPF.WriteRowNoFilter({'user': user})
|
csvPF.WriteRowNoFilter({'user': user})
|
||||||
else:
|
elif aggregateUsersBy != 'user':
|
||||||
if results:
|
if results:
|
||||||
for token in results:
|
for token in results:
|
||||||
tokcid = token['clientId']
|
tokcid = token['clientId']
|
||||||
@@ -66561,6 +66566,8 @@ def _printShowTokens(entityType, users):
|
|||||||
if tokname not in tokenNameIdMap:
|
if tokname not in tokenNameIdMap:
|
||||||
tokenNameIdMap[tokname] = set()
|
tokenNameIdMap[tokname] = set()
|
||||||
tokenNameIdMap[tokname].add(tokcid)
|
tokenNameIdMap[tokname].add(tokcid)
|
||||||
|
else: # aggregateUsersBy == 'user':
|
||||||
|
aggregateTokensById[user] = jcount
|
||||||
except (GAPI.notFound, GAPI.resourceNotFound) as e:
|
except (GAPI.notFound, GAPI.resourceNotFound) as e:
|
||||||
entityActionFailedWarning([Ent.USER, user, Ent.ACCESS_TOKEN, clientId], str(e), i, count)
|
entityActionFailedWarning([Ent.USER, user, Ent.ACCESS_TOKEN, clientId], str(e), i, count)
|
||||||
except (GAPI.userNotFound, GAPI.domainNotFound, GAPI.domainCannotUseApis, GAPI.forbidden, GAPI.badRequest):
|
except (GAPI.userNotFound, GAPI.domainNotFound, GAPI.domainCannotUseApis, GAPI.forbidden, GAPI.badRequest):
|
||||||
@@ -66593,6 +66600,16 @@ def _printShowTokens(entityType, users):
|
|||||||
for _, tokenIds in sorted(iter(tokenNameIdMap.items())):
|
for _, tokenIds in sorted(iter(tokenNameIdMap.items())):
|
||||||
for tokcid in sorted(tokenIds):
|
for tokcid in sorted(tokenIds):
|
||||||
_printToken(aggregateTokensById[tokcid])
|
_printToken(aggregateTokensById[tokcid])
|
||||||
|
else: # aggregateUsersBy == 'user':
|
||||||
|
if not csvPF:
|
||||||
|
jcount = len(aggregateTokensById)
|
||||||
|
j = 0
|
||||||
|
for user, count in sorted(iter(aggregateTokensById.items())):
|
||||||
|
j += 1
|
||||||
|
printEntityKVList([Ent.USER, user], [Ent.Plural(Ent.ACCESS_TOKEN), count], j, jcount)
|
||||||
|
else:
|
||||||
|
for user, count in sorted(iter(aggregateTokensById.items())):
|
||||||
|
csvPF.WriteRow({'user': user, 'tokenCount': count})
|
||||||
if csvPF:
|
if csvPF:
|
||||||
csvPF.writeCSVfile('OAuth Tokens')
|
csvPF.writeCSVfile('OAuth Tokens')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user