Skip to content

Instantly share code, notes, and snippets.

@KyMidd
Created July 23, 2025 00:44
Show Gist options
  • Select an option

  • Save KyMidd/c61f33208a493997681ee8c98b97a68d to your computer and use it in GitHub Desktop.

Select an option

Save KyMidd/c61f33208a493997681ee8c98b97a68d to your computer and use it in GitHub Desktop.
def get_teams_bearer_token(TENANT_ID, CLIENT_ID, CLIENT_SECRET):
# Token endpoint for Azure AD - multi tenant
token_url = f"https://login.microsoftonline.com/botframework.com/oauth2/v2.0/token"
# Bot Framework requires this scope
scope = "https://api.botframework.com/.default"
# Build the request
payload = {
"grant_type": "client_credentials",
"client_id": CLIENT_ID,
"client_secret": CLIENT_SECRET,
"scope": scope,
}
# Request the token
response = requests.post(token_url, data=payload)
response.raise_for_status() # This will throw an error if the request fails
# Extract the token
bearer_token = response.json()["access_token"]
return bearer_token
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment