This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
### | |
### Shell script to get an access token for a user | |
### using Google 3-legged OAuth. | |
### | |
### Example to show your quota usage: | |
### | |
### # first run is to authorize. | |
### bash --credentials-file drive-quota.json \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
''' | |
Delete old Cloud Workstation Disks | |
WARNING: This script will delete disks and all data on them. It should be | |
considered "proof of concept" quality and should be customized to fit your | |
environmental needs, checked for logic errors and monitored. I am not | |
responsible for data loss by using this script. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
refresh_access_token () | |
{ | |
echo "Old access token: $access_token" | |
refresh_result=$(curl -s https://accounts.google.com/o/oauth2/token \ | |
-H "Content-Type: application/x-www-form-urlencoded" \ | |
-d refresh_token=$refresh_token \ | |
-d client_id=$client_id \ | |
-d client_secret=$client_secret \ | |
-d grant_type=refresh_token) | |
access_token=$(echo -e "$refresh_result" | \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
### | |
### Shell script to use Google service account and optionally | |
### domain-wide delegation (DwD). | |
### | |
### This script will ultimately output an access token that can be used to | |
### call Google APIs as the service account or the Workspace user in DwD. | |
### | |
### Example to show a Workspace user's IMAP settings: | |
### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
runtime: python311 | |
handlers: | |
- url: / | |
secure: always | |
script: auto | |
redirect_http_response_code: 301 | |
- url: /debug | |
secure: always |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export cpucount=$(nproc --all) | |
cd ~ | |
mkdir src | |
cd src | |
export LD_LIBRARY_PATH="${HOME}/ssl/lib:${HOME}/python/lib" | |
git clone https://github.com/openssl/openssl.git | |
cd openssl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
### This script requires a service account private key JSON credentials file. | |
### The service account should be granted an admin role in your domain that | |
### authorizes it to create users. See: | |
### | |
### https://support.google.com/a/answer/9807615?hl=en&ref_topic=9832445&fl=1#zippy=%2Cassign-a-role-to-a-service-account | |
### | |
### This script requires PyJWT and requests. Install it by running: | |
### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
### | |
### PoC to apply Context Aware Access rules (generally IP ranges or geographical regions) to Google API calls. | |
### | |
### This script will ultimately generate an access token that can be used to call Workspace APIs as a user. | |
### | |
### Example run: | |
### | |
### export access_token=$(./dwd-with-caa.sh \ | |
### --credentials-file oauth2service.json \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
''' | |
Set user's Gmail vacation message | |
''' | |
import argparse | |
import http.client | |
from json import dumps | |
import time |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
### | |
### Shell script to use update a user's away message for the next week. | |
### Utilizes Google domain-wide delegation (DwD). | |
### | |
### Example to turn on vacation message for a user: | |
### | |
### bash vacation.sh --credentials-file oauth2service.json \ | |
### --user jdoe@acme.com \ | |
### --autoreply 'I am out of the office this week" |
NewerOlder