forked from Shinonome/dots-hyprland
add screen translation
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
source $(eval echo $ILLOGICAL_IMPULSE_VIRTUAL_ENV)/bin/activate
|
||||
"$SCRIPT_DIR/token_from_key.py" "$@"
|
||||
deactivate
|
||||
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
import json
|
||||
import google.auth.transport.requests
|
||||
import google.oauth2.service_account
|
||||
|
||||
def get_token(json_str):
|
||||
try:
|
||||
# Load the string into a dictionary
|
||||
info = json.loads(json_str)
|
||||
|
||||
# Initialize credentials
|
||||
creds = google.oauth2.service_account.Credentials.from_service_account_info(info)
|
||||
scoped_creds = creds.with_scopes(['https://www.googleapis.com/auth/cloud-platform'])
|
||||
|
||||
# Refresh to get the access token
|
||||
request = google.auth.transport.requests.Request()
|
||||
scoped_creds.refresh(request)
|
||||
|
||||
print(scoped_creds.token)
|
||||
except Exception as e:
|
||||
sys.stderr.write(f"Error: {str(e)}\n")
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 2:
|
||||
sys.stderr.write("Usage: python3 get_token.py '<json_string>'\n")
|
||||
sys.exit(1)
|
||||
|
||||
get_token(sys.argv[1])
|
||||
Reference in New Issue
Block a user