28 lines
721 B
Python
Executable File
28 lines
721 B
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
Get an Azure DevOps token and print it in a format suitable for exporting as an environment variable.
|
|
|
|
Usage:
|
|
eval $(python get-token.py)
|
|
|
|
or
|
|
|
|
python get-token.py > set-ado-token.sh
|
|
source set-ado-token.sh
|
|
|
|
Now you can use the ADO_TOKEN environment variable, for example using curl:
|
|
|
|
curl -H "Authorization: Bearer $ADO_TOKEN" https://dev.azure.com/your_organization/_apis/projects?api-version=7.1
|
|
"""
|
|
|
|
from sk.azure import get_token
|
|
|
|
token = get_token(
|
|
tenant_id="a7740229-47b6-45de-ad22-83721462b1bf",
|
|
client_id="840671c4-5dc4-40e5-aab9-7c3a07bbd652",
|
|
pem_path="./slawek-mba.pem"
|
|
)
|
|
|
|
# print(f"Obtained token: {token}")
|
|
|
|
print(f"export ADO_TOKEN='{token}'") |