Skip to content

Instantly share code, notes, and snippets.

@KyMidd
Created July 9, 2025 02:52
Show Gist options
  • Select an option

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

Select an option

Save KyMidd/bf206f2bef498f1eb2c16aff439cea2c to your computer and use it in GitHub Desktop.
def build_oauth_url(tenant_id, client_id, aad_object_id, scope):
base_url = f"https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/authorize"
# Build redirect URI
redirect_uri = f"{redirect_function_url}/callback"
query_params = {
"client_id": client_id,
"response_type": "code",
"redirect_uri": redirect_uri,
"response_mode": "query",
"scope": scope,
"state": aad_object_id
}
# Encode the query parameters
oauth_url = f"{base_url}?{urlencode(query_params)}"
# Debug
if os.environ.get("VERA_DEBUG") == "True":
print("🔗 OAuth URL encoded:", oauth_url)
return oauth_url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment