Skip to main content

A lightweight tool to fetch Azure AD access tokens.

Project description

token-service-tool

token-service-tool is a lightweight and developer-friendly Python utility designed to fetch OAuth2 access tokens from Azure Active Directory (Azure AD) using the Client Credentials flow.

This package is ideal for microservices, backend applications, internal tools, automation scripts, or any environment where a secure and minimal method of retrieving access tokens is required—without bringing in heavy Azure SDK dependencies.


Features

  • ✔ Minimal API surface — easy to integrate
  • ✔ Stateless: no environment variable dependency
  • ✔ No Azure CLI or SDK required
  • ✔ Pure Python implementation using requests
  • ✔ Consistent error handling with clear messages
  • ✔ Fully unit-tested (mocked, no network calls)
  • ✔ Compatible with serverless functions, containers, and CI/CD pipelines

Installation

Install the latest version from PyPI:

pip install token-service-tool

Usage

from token_service_tool import TokenService

service = TokenService(
    client_id="YOUR_CLIENT_ID",
    client_secret="YOUR_CLIENT_SECRET",
    tenant_id="YOUR_TENANT_ID",
    scope="https://graph.microsoft.com/.default",
    token_url=f"https://login.microsoftonline.com/YOUR_TENANT_ID/oauth2/v2.0/token",
    grant_type="client_credentials"
)

access_token = service.get_access_token()
print("Access Token:", access_token)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

token_service_tool-0.1.1.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

token_service_tool-0.1.1-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file token_service_tool-0.1.1.tar.gz.

File metadata

  • Download URL: token_service_tool-0.1.1.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.8

File hashes

Hashes for token_service_tool-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f33187f91e95e0587de6f0e2866e448b48d804f2ba6b75b24689ff96437e1024
MD5 3ec87458ac4523f1f5825ca626b7189b
BLAKE2b-256 e722075aea63c2dbe6d47c4e5a03ba7c8e60409a99a6199f87a3f0b06fc82ebf

See more details on using hashes here.

File details

Details for the file token_service_tool-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for token_service_tool-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b16f5be3fc6ce5e8dd77ba04b98a701158328a97d2d74c521f66b7bdebd1bc3a
MD5 f3b4b3a94a8646ce0d345de7ae385f9f
BLAKE2b-256 8f97e201ffb8e497fc5b4a5806970003c48577b2ef2fd276a3573796fe760f0b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page