PyARCrbac is a Python library that provides functions for retrieving tokens from azure arc-enabled servers using the local metadata service. It can be used to obtain access tokens for Azure resources.
pip3 install pyarcrbacMake sure you have the necessary permissions and environment variables set up to access the azure metadata service.
Here's an example of how to use PyARCrbac to retrieve an graph access token:
from pyarcrbac import pyrbac
import requests
def fetch_device_data():
url = "https://graph.microsoft.com/v1.0/devices"
headers = {"Authorization": f"Bearer {pyrbac.graph_token()}"}
response = requests.get(url, headers=headers)
return response.json()Here's an example of how to use PyARCrbac to retrieve an management access token:
from pyarcrbac import pyrbac
import requests
def fetch_device_data():
url = "https://management.azure.com/subscriptions"
headers = {"Authorization": f"Bearer {pyrbac.mgmt_token()}"}
response = requests.get(url, headers=headers)
return response.json()Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.
This project is licensed under the MIT License.
For any questions or inquiries, please open an issue.
I am not responsible for any damage and/or misuse as a result of using this lib.