تدفق OAuth في MCP
كيف يحصل العملاء على رموز مميّزة للخوادم المحمية.
تدفق OAuth في MCP درس مجاني في MCP Academy على CoddyKit. هذا هو الدرس 3 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في MCP Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة MCP Academy 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
Why Static Tokens Fall Short
A single shared token works for one user, but real apps have many. OAuth gives each client its own token without handing out one master secret. 🔑
OAuth in One Sentence
OAuth lets a client obtain a short-lived access token by proving its identity, instead of you mailing secrets around by hand.
The Three Players
There is the client that wants access, the user who approves it, and the authorization server that issues the tokens.
MCP Servers Advertise Auth
A protected MCP server can tell clients where to authenticate by exposing its authorization server metadata. Clients read it to start the flow.
The Authorization Request
The client kicks things off by sending the user to the authorization server to log in and grant consent.
User Grants Consent
The user reviews what access is being asked for and approves. Nothing is issued until that consent step happens.
Exchanging the Code
The authorization server hands back a short authorization code, which the client swaps for a real access token.
POST /token
grant_type=authorization_code
code=AUTH_CODE_HEREThe Access Token Arrives
The token endpoint returns an access token. The client then sends it as a bearer token on every MCP request.
{
"access_token": "eyJhbGci...",
"token_type": "Bearer",
"expires_in": 3600
}Tokens Expire on Purpose
Access tokens are short-lived. When one expires, the client must refresh or re-authenticate rather than reuse it forever.
Refresh Without Re-Login
A refresh token lets the client get a fresh access token quietly, so the user is not prompted to log in every hour.
The Server Just Validates
Your MCP server does not run the login screen. It only validates the access token it receives on each incoming request.
Quick Check
Trace one step of the flow.
Recap: Earn the Token
OAuth turns "share a secret" into "earn a token": consent, exchange a code, get a short-lived access token, refresh as needed. 🔄
الأسئلة الشائعة
هل درس «تدفق OAuth في MCP» مجاني؟
نعم — نص درس «تدفق OAuth في MCP» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة MCP Academy، انتقل إلى CoddyKit PRO. تتضمن دورة MCP Academy 4 دروس في المجموع.
ماذا ستتعلم في «تدفق OAuth في MCP»؟
كيف يحصل العملاء على رموز مميّزة للخوادم المحمية. تتمرن على MCP Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ MCP Academy؟
لا تُشترط خبرة سابقة. MCP Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 3 من أصل 4.
كم من الوقت يستغرق درس «تدفق OAuth في MCP»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس MCP Academy هذا؟
نعم. كل درس في MCP Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- لماذا تحتاج الخوادم البعيدة إلى المصادقة
- الرموز المميّزة لحاملها والرؤوس
- تدفق OAuth في MCP
- تحديد نطاق ما يمكن للرمز المميّز تنفيذه