惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Tailwind CSS Blog
C
CERT Recently Published Vulnerability Notes
V
Visual Studio Blog
O
OpenAI News
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
The Cloudflare Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Last Week in AI
Last Week in AI
Y
Y Combinator Blog
博客园 - 聂微东
L
Lohrmann on Cybersecurity
P
Proofpoint News Feed
Simon Willison's Weblog
Simon Willison's Weblog
G
GRAHAM CLULEY
AI
AI
S
Security @ Cisco Blogs
TaoSecurity Blog
TaoSecurity Blog
Jina AI
Jina AI
W
WeLiveSecurity
大猫的无限游戏
大猫的无限游戏
腾讯CDC
K
Kaspersky official blog
Hugging Face - Blog
Hugging Face - Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
宝玉的分享
宝玉的分享
AWS News Blog
AWS News Blog
月光博客
月光博客
P
Palo Alto Networks Blog
小众软件
小众软件
V2EX - 技术
V2EX - 技术
罗磊的独立博客
V
Vulnerabilities – Threatpost
J
Java Code Geeks
H
Heimdal Security Blog
S
SegmentFault 最新的问题
博客园 - 【当耐特】
Cyberwarzone
Cyberwarzone
S
Schneier on Security
博客园_首页
T
The Exploit Database - CXSecurity.com
Attack and Defense Labs
Attack and Defense Labs
Forbes - Security
Forbes - Security
N
News | PayPal Newsroom
IT之家
IT之家
Project Zero
Project Zero
Help Net Security
Help Net Security
P
Privacy International News Feed
爱范儿
爱范儿
D
Darknet – Hacking Tools, Hacker News & Cyber Security
T
Threat Research - Cisco Blogs

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Build AI Agents That Securely Act on Behalf of Any User
Harsh · 2026-05-04 · via DEV Community

The 3 AM Nightmare

Last week, I let an AI agent run loose on my production server. It was fine — until 3 AM. To interact with the agent, a user must first authenticate across Gmail, a support desk, and a payment platform — all before the agent takes its first action.

Permission denied. Permission denied. Permission denied.

Three different connectors. Three different auth systems. One very tired developer. That's when I realized: My auth layer had no idea how to keep my AI agent's access tokens alive.

In a traditional SaaS app a human sits at a keyboard, logging in once, getting an access token, and doing their work.

AI agents are different, they need stricter controls over how long tokens live and exactly when they get refreshed. They run autonomously, act on behalf of multiple users simultaneously, and need access that is scoped and auditable. When those requirements clash with the status quo of existing auth systems, you get 3 AM wake-up calls.


The Real Problem: Why Traditional Auth Fails for AI Agents

Here's what happens when you try to use traditional access controls for AI agents:

Problem Explanation
Context blindness Agent doesn't know which user it's acting for
Scope creep Agents ask for too many access rights upfront
Audit nightmare You can't tell if an agent or a human took an action
Short-lived sessions Agents need access that expires automatically

This isn't theory. I ran into every single one of these issues while building an agent that needed to triage customer support tickets by reading Gmail, checking a CRM, and updating a database all without human intervention.

The core issue is that authentication flows was designed for users, not agents. An agent acting on behalf of 100 different users isn't one user with one role it's a dynamic, context-aware entity that needs access granted, scoped, and revoked in real time.


Enter AgentKit by Scalekit

Scalekit built AgentKit specifically for this problem. Instead of hacking existing auth layer, AgentKit adds an access orchestration layer designed from the ground up for agents:

  • Delegated auth — The agent acts on behalf of specific users, not as a global service account
  • Scoped access — Only what it needs, for exactly as long as it needs it
  • Built-in audit logs — Every access request is recorded, including which agent, which user, and which action

📌 Note: Scalekit handles orchestrating auth for each user and connector. Additionally, each connector (Google, HubSpot, etc.) also steps in to enforce its own native access policies such as scopes. The focus here is the orchestration layer — not the policies enforced by the underlying services.

The best part? It takes about 15 minutes to implement. Let me show you exactly how.


Prerequisites

Before we start, you'll need:

  • Python 3.12+ installed
  • A Scalekit account (sign up for free)
  • A Gmail account (for testing)
  • 15 minutes of focused time

Using a coding agent like Claude Code?

Install the plugin:

claude plugin marketplace add scalekit-inc/claude-code-authstack && claude plugin install agent-auth@scalekit-auth-stack

Enter fullscreen mode Exit fullscreen mode

Or if you prefer skills:

npx skills add scalekit-inc/skills --skill integrating-agent-auth

Enter fullscreen mode Exit fullscreen mode


Step 1: Setting Up Your Python Environment

First, let's create a dedicated virtual environment for the AgentKit project. Isolating dependencies is a good habit and prevents version conflicts with other projects.

Create the project folder and virtual environment:

cd Desktop
mkdir scalekit-demo
cd scalekit-demo
py -3.12 -m venv scalekit-env
scalekit-env\Scripts\activate

Enter fullscreen mode Exit fullscreen mode

Verify your Python version:

python --version
# Output: Python 3.12.9

Enter fullscreen mode Exit fullscreen mode

Once the virtual environment is active, you'll see (scalekit-env) at the start of your command prompt. Upgrade pip to the latest version:

python -m pip install --upgrade pip
# Successfully installed pip-26.1

Enter fullscreen mode Exit fullscreen mode

Virtual environment activated — (scalekit-env) confirms isolation from system Python

Pip upgraded from 24.3.1 to 26.1 — ready for smooth package installation


Step 2: Installing and Verifying the Scalekit SDK

Now install the official Scalekit Python SDK:

pip install scalekit-sdk-python

Enter fullscreen mode Exit fullscreen mode

This single command installs the SDK along with all required dependencies: grpcio, cryptography, requests, PyJWT, pydantic, and more.

Successfully installed Faker-25.8.0 PyJWT-2.12.1 annotated-types-0.7.0 anyio-4.13.0
attrs-26.1.0 beautifulsoup4-4.14.3 ... scalekit-sdk-python-2.9.0 ...

Enter fullscreen mode Exit fullscreen mode

Scalekit SDK 2.9.0 installed successfully with all dependencies

Scalekit SDK 2.9.0 successfully installed along with grpcio, cryptography, and other dependencies

Once installed, verify the SDK is working by initializing the Scalekit client in your Python code:

from scalekit import ScalekitClient
import os

sc = ScalekitClient(
    env_url="https://devagentlabs.scalekit.dev",
    client_id="skc_123451560272397061",
    client_secret=os.environ.get("SCALEKIT_CLIENT_SECRET")
)

print("✅ SDK initialized!")

Enter fullscreen mode Exit fullscreen mode

Note: In development, you can test the import and basic initialization. The full token exchange — where your agent retrieves the OAuth token for a specific user — is handled automatically by Scalekit's SDK when you call the connected accounts API. This means you don't manage token refresh, expiry, or scope validation yourself.

Once initialized, your agent can:

  • List all connected accounts for a given user
  • Check authorization status before making API calls
  • Fetch Gmail data through the connector without ever seeing the raw OAuth tokens

Step 3: Getting Your API Credentials

Navigate to app.scalekit.dev → Settings → API Credentials. Make sure you're in the Development environment (check the top-right dropdown — it should say "Devagentlabs Dev").

You'll need three values:

Variable Purpose
Environment URL Base URL for all API calls (e.g., https://devagentlabs.scalekit.dev)
Client ID Unique identifier for your application
Client Secret Secret key used to authenticate your requests

⚠️ Security note: Never hardcode your Client Secret in source code or commit it to GitHub. Use environment variables in production:

export SCALEKIT_CLIENT_SECRET="your_secret_here"

API Credentials — Environment URL, Client ID, and masked Client Secret

Settings → API Credentials page showing Environment URL, Client ID, and masked Client Secret


Step 4: Creating a Gmail Connector

With credentials ready, let's connect Gmail. Navigate to Connections → + Create Connection → Select Gmail.

Configure the connector with these settings:

  • Connection Name: my-gmail (acts as a unique identifier/primary key for this integration)
  • Authentication Type: OAuth
  • OAuth Credentials: Use Scalekit credentials (for development — uses Scalekit's managed OAuth app)
  • Scopes: https://www.googleapis.com/auth/gmail.readonly

💡 Best practice: Always request the minimum access needed. Read-only access (gmail.readonly) is sufficient for most agent use cases like email triage, summarization, or monitoring. Never request write access unless your agent actually needs to send or modify emails.

Gmail connector configured with gmail.readonly scope — least-privilege principle

Configuring the Gmail connector — note the read-only scope following the least-privilege principle


Step 5: Authorizing a Connected Account

Now we'll create a connected account — this is the link between a specific user and the Gmail connector. This is where multi-service user access orchestration comes to life: once a user authorizes here, any agent acting on their behalf can request their credentials programmatically.

  1. Go to Connected Accounts → + Add Account
  2. Set a User ID (e.g., test-user-123) and select the my-gmail connection
  3. Click Create
  4. Generate an authorization link and open it in your browser
  5. Sign in with your Google account and click Allow to grant read-only access

After the OAuth flow completes, the account status changes from "Pending" to "Connected".

💡 Development tip: Google may show an "unverified app" warning during the OAuth flow. This is expected — click "Advanced" → "Go to scalekit.dev (unsafe)" → "Allow". The app will be properly verified for production use.

Connected account test-user-123 — Status: Connected

Connected account successfully authorized — the agent can now access Gmail on behalf of test-user-123


Step 6: Going to Production

Before shipping to production, it's a best practice to set up user verification to ensure only authenticated users can trigger agent actions on their behalf.

🔐 Best practice: Review the AgentKit User Verification guide to understand how to validate user identity before your agent performs any actions in production.

This ensures your agent always acts on behalf of a verified user — not an anonymous or unauthorized request.


What's Next?

With the connected account active, your AI agent now has a proper access orchestration layer. It can:

  • Read user emails via the Gmail connector with scoped, auditable access
  • Check authorization status programmatically before each operation
  • Let Scalekit handle token refresh, expiry, and scope validation automatically

Beyond Gmail, AgentKit supports 40+ connectors including Slack, GitHub, Google Calendar, Google Drive, and more. The same pattern connect once, delegate safely, audit everything applies across all of them.

Check out the AgentKit documentation to explore the full connector catalog and advanced use cases like multi-user delegation and access policies.


Conclusion

Traditional authorization wasn't built for AI agents. When your agent needs to act on behalf of multiple users across multiple services, legacy access controls become a liability not a safeguard.

Scalekit AgentKit provides a purpose-built access orchestration solution with:

  • Just-in-time access requests — agents get access only when needed
  • Automatic token management — no manual refresh logic
  • Complete audit trails — every access request is logged
  • 15-minute implementation — as proven in this tutorial

Imagine a user authenticates once. The AI agent then fetches the last 5 unread emails from a teammate, drafts a summary, and posts it to a Slack channel all without re-prompting for credentials. That's the power of Scalekit's delegated auth.

The 3 AM access crashes? Gone.


This article is sponsored by Scalekit. All code, opinions, and 3 AM debugging stories are my own.