mirror of
https://github.com/GAM-team/GAM.git
synced 2026-06-25 16: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
|
||||
|
||||
### 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
|
||||
|
||||
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
|
||||
|
||||
|
||||
@@ -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$ ./gam version
|
||||
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>
|
||||
Python 3.12.4 64-bit final
|
||||
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>gam version
|
||||
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>
|
||||
Python 3.12.4 64-bit final
|
||||
Windows-10-10.0.17134 AMD64
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
- [Definitions](#definitions)
|
||||
- [Delete a user's token](#delete-a-users-token)
|
||||
- [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)
|
||||
|
||||
## API documentation
|
||||
@@ -27,6 +28,9 @@ gam <UserTypeEntity> show tokens|token|3lo|oauth [clientid <ClientID>]
|
||||
gam print tokens|token [todrive <ToDriveAttributes>*] [clientid <ClientID>]
|
||||
[orderby clientid|id|appname|displaytext] [delimiter <Character>]
|
||||
[<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.
|
||||
|
||||
@@ -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
|
||||
```
|
||||
|
||||
## 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
|
||||
```
|
||||
gam <UserTypeEntity> print tokens|token [todrive <ToDriveAttributes>*] [clientid <ClientID>]
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Print the current version of Gam with details
|
||||
```
|
||||
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>
|
||||
Python 3.12.4 64-bit final
|
||||
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
|
||||
```
|
||||
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>
|
||||
Python 3.12.4 64-bit final
|
||||
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
|
||||
```
|
||||
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>
|
||||
Python 3.12.4 64-bit final
|
||||
MacOS Sonoma 14.5 x86_64
|
||||
@@ -64,7 +64,7 @@ MacOS High Sierra 10.13.6 x86_64
|
||||
Path: /Users/Admin/bin/gamadv-xtd3
|
||||
Version Check:
|
||||
Current: 5.35.08
|
||||
Latest: 6.77.08
|
||||
Latest: 6.77.09
|
||||
echo $?
|
||||
1
|
||||
```
|
||||
@@ -72,7 +72,7 @@ echo $?
|
||||
Print the current version number without details
|
||||
```
|
||||
gam version simple
|
||||
6.77.08
|
||||
6.77.09
|
||||
```
|
||||
In Linux/MacOS you can do:
|
||||
```
|
||||
@@ -82,7 +82,7 @@ echo $VER
|
||||
Print the current version of Gam and address of this Wiki
|
||||
```
|
||||
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>
|
||||
Python 3.12.4 64-bit final
|
||||
MacOS Sonoma 14.5 x86_64
|
||||
|
||||
@@ -8181,11 +8181,18 @@ gam <UserTypeEntity> show sheetrange <DriveFileEntity>
|
||||
gam <UserTypeEntity> delete tokens 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>]
|
||||
[aggregateby|orderby clientid|id|appname|displaytext]
|
||||
[usertokencounts|(aggregateusersby|orderby clientid|id|appname|displaytext)]
|
||||
[delimiter <Character>]
|
||||
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>]
|
||||
|
||||
# Users - YouTube
|
||||
|
||||
@@ -2,10 +2,15 @@
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
|
||||
@@ -66434,7 +66434,7 @@ def deleteTokens(users):
|
||||
|
||||
TOKENS_FIELDS_TITLES = ['clientId', 'displayText', 'anonymous', 'nativeApp', 'userKey', 'scopes']
|
||||
TOKENS_AGGREGATE_FIELDS_TITLES = ['clientId', 'displayText', 'anonymous', 'nativeApp', 'users', 'scopes']
|
||||
TOKENS_ORDERBY_CHOICE_MAP = {
|
||||
TOKENS_AGGREGATE_ORDERBY_CHOICE_MAP = {
|
||||
'clientid': 'clientId',
|
||||
'id': 'clientId',
|
||||
'displaytext': 'displayText',
|
||||
@@ -66443,6 +66443,7 @@ TOKENS_ORDERBY_CHOICE_MAP = {
|
||||
TOKENS_TITLE_MAP = {
|
||||
'clientId': 'Client ID',
|
||||
'displayText': 'App Name',
|
||||
'user': 'user',
|
||||
}
|
||||
|
||||
def _printShowTokens(entityType, users):
|
||||
@@ -66484,11 +66485,13 @@ def _printShowTokens(entityType, users):
|
||||
elif myarg == 'clientid':
|
||||
clientId = commonClientIds(getString(Cmd.OB_CLIENT_ID))
|
||||
elif myarg == 'orderby':
|
||||
orderBy = getChoice(TOKENS_ORDERBY_CHOICE_MAP, mapChoice=True)
|
||||
orderBy = getChoice(TOKENS_AGGREGATE_ORDERBY_CHOICE_MAP, mapChoice=True)
|
||||
elif myarg == 'aggregateusersby':
|
||||
aggregateUsersBy = getChoice(TOKENS_ORDERBY_CHOICE_MAP, mapChoice=True)
|
||||
aggregateUsersBy = getChoice(TOKENS_AGGREGATE_ORDERBY_CHOICE_MAP, mapChoice=True)
|
||||
if aggregateUsersBy == 'displayText':
|
||||
tokenNameIdMap = {}
|
||||
elif myarg == 'usertokencounts':
|
||||
aggregateUsersBy = 'user'
|
||||
elif myarg == 'delimiter':
|
||||
delimiter = getCharacter()
|
||||
elif not entityType:
|
||||
@@ -66501,8 +66504,10 @@ def _printShowTokens(entityType, users):
|
||||
if csvPF:
|
||||
if not aggregateUsersBy:
|
||||
csvPF.SetTitles(['user']+TOKENS_FIELDS_TITLES)
|
||||
else:
|
||||
elif aggregateUsersBy != 'user':
|
||||
csvPF.SetTitles(TOKENS_AGGREGATE_FIELDS_TITLES)
|
||||
else:
|
||||
csvPF.SetTitles(['user', 'tokenCount'])
|
||||
else:
|
||||
if not aggregateUsersBy:
|
||||
tokenTitle = TOKENS_TITLE_MAP[orderBy]
|
||||
@@ -66527,8 +66532,8 @@ def _printShowTokens(entityType, users):
|
||||
throwReasons=[GAPI.USER_NOT_FOUND, GAPI.DOMAIN_NOT_FOUND,
|
||||
GAPI.DOMAIN_CANNOT_USE_APIS, GAPI.FORBIDDEN, GAPI.BAD_REQUEST],
|
||||
userKey=user, fields=f'items({fields})')
|
||||
jcount = len(results)
|
||||
if not aggregateUsersBy:
|
||||
jcount = len(results)
|
||||
if not csvPF:
|
||||
entityPerformActionNumItems([Ent.USER, user], jcount, Ent.ACCESS_TOKEN, i, count)
|
||||
Ind.Increment()
|
||||
@@ -66547,7 +66552,7 @@ def _printShowTokens(entityType, users):
|
||||
csvPF.WriteRow(row)
|
||||
elif GC.Values[GC.CSV_OUTPUT_USERS_AUDIT]:
|
||||
csvPF.WriteRowNoFilter({'user': user})
|
||||
else:
|
||||
elif aggregateUsersBy != 'user':
|
||||
if results:
|
||||
for token in results:
|
||||
tokcid = token['clientId']
|
||||
@@ -66561,6 +66566,8 @@ def _printShowTokens(entityType, users):
|
||||
if tokname not in tokenNameIdMap:
|
||||
tokenNameIdMap[tokname] = set()
|
||||
tokenNameIdMap[tokname].add(tokcid)
|
||||
else: # aggregateUsersBy == 'user':
|
||||
aggregateTokensById[user] = jcount
|
||||
except (GAPI.notFound, GAPI.resourceNotFound) as e:
|
||||
entityActionFailedWarning([Ent.USER, user, Ent.ACCESS_TOKEN, clientId], str(e), i, count)
|
||||
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 tokcid in sorted(tokenIds):
|
||||
_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:
|
||||
csvPF.writeCSVfile('OAuth Tokens')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user