We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Amit-confer/Gmail-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
authenticate.py•1.17 kB
import os
from pathlib import Path
from google_auth_oauthlib.flow import InstalledAppFlow
from auth import SCOPES
def authenticate_local():
"""Authenticates using the local browser flow."""
creds_path = Path("credentials.json")
token_path = Path("token.json")
if not creds_path.exists():
print(f"❌ Error: {creds_path} not found.")
print("Please download it from Google Cloud Console and place it here.")
return
print("--- Gmail Local Authentication ---")
print("Launching browser for authentication...")
try:
flow = InstalledAppFlow.from_client_secrets_file(
str(creds_path), SCOPES
)
# This opens the browser locally
creds = flow.run_local_server(port=0)
# Save the token
token_path.write_text(creds.to_json())
print(f"\n✅ Authentication successful!")
print(f"Token saved to: {token_path.absolute()}")
print("\nYou can now configure your MCP client to run 'server.py'.")
except Exception as e:
print(f"\n❌ Authentication failed: {e}")
if __name__ == "__main__":
authenticate_local()