bitcoin
bitcoin

$64566.812908 USD

0.23%

ethereum
ethereum

$1810.474514 USD

0.98%

tether
tether

$0.999022 USD

-0.03%

bnb
bnb

$590.524043 USD

0.06%

usd-coin
usd-coin

$0.999830 USD

0.01%

xrp
xrp

$0.951385 USD

-0.53%

solana
solana

$70.791567 USD

0.57%

tron
tron

$0.302344 USD

-1.59%

hyperliquid
hyperliquid

$66.043751 USD

0.99%

zcash
zcash

$884.280716 USD

-1.46%

dogecoin
dogecoin

$0.058467 USD

0.99%

monero
monero

$482.505734 USD

-1.49%

unus-sed-leo
unus-sed-leo

$9.190973 USD

0.78%

chainlink
chainlink

$9.081451 USD

-0.25%

cardano
cardano

$0.151877 USD

0.97%

Cryptocurrency News Video

FastAPI OAuth2 Scopes: Security(). SecurityScopes. Read-Only Tokens & insufficient_scope | #43

Nov 11, 2026 at 01:30 pm Nilesh Technology

An admin account – but a token that can only read. In Lesson 43 of the FastAPI Complete Tutorial (Beginner → Deployment), we add OAuth2 scopes to our API, step by step, in a fresh, small async project with users, courses and the roles from Video 42. Roles vs scopes: a role belongs to the user, a scope belongs to the token. Then the code line by line: a list of scopes with descriptions, which scopes each role may ever get, and a login where the client asks for scopes (form.scopes) and the server grants only the intersection with the role – an unknown scope is a 400, and the answer says what was really granted. FastAPI's tools: OAuth2PasswordBearer(scopes=...), Security() – Depends with scopes – and SecurityScopes, which collects the scopes of the whole dependency chain. A get_current_user that checks the token's scopes AND the user's role on every request, and a 403 with WWW-Authenticate: Bearer error="insufficient_scope" (RFC 6750) – and why FastAPI's own tutorial uses 401. Demos: who gets which scopes, 5 tokens against 4 endpoints, a demoted teacher whose old token stops working, how scopes stack and cache, the Authorize dialog in Swagger with scope checkboxes – and 15 tests on SQLite and PostgreSQL. 💻 Code for this video: https://github.com/nileshborate/fastapi/tree/main/43-oauth2-scopes 📂 Full course code: https://github.com/nileshborate/fastapi ▶️ Full playlist: https://www.youtube.com/playlist?list=PLBjgbZvHwQmg 🌐 Website: https://www.nileshtechnology.in ⏱️ CHAPTERS 0:00 Intro 0:05 Homework answer (Video 42): course students, blocking users 1:41 A read-only token for a script 2:29 Today's plan 2:55 Where to get the code (GitHub) 3:32 Roles vs scopes 4:53 roles.py: SCOPES, ROLE_SCOPES, grant_scopes 6:24 Logging in with scopes 7:51 Who asks for what (demo) 8:47 Security() and SecurityScopes 10:33 get_current_user, line by line 12:01 401 or 403? insufficient_scope 13:06 Scopes on the endpoints and routers 14:17 Five tokens, four endpoints (demo) 15:32 The role still counts (demo) 16:10 How SecurityScopes collects scopes (demo) 17:30 Swagger: pick your scopes 18:19 Tests 19:41 3 common mistakes 20:16 Interview questions 21:13 Recap, homework & what's next 📝 HOMEWORK 1. A new scope "courses:delete" (admins only) and DELETE /courses/{course_id} that needs it 2. GET /me/token – the scopes of the token you're using right now, and when it expires (hint: a dependency that returns the decoded claims) 3. Tests for both The answer is in the next video! 🎯 INTERVIEW QUESTIONS IN THIS VIDEO • What are OAuth2 scopes? • How do you use scopes in FastAPI? • Roles or scopes – which one do you need? ⏭️ Next video: Email Verification and Password Reset – signed, expiring, one-time links 👍 Like, subscribe to Nilesh Technology and press the bell for the next lesson! #FastAPI #Python #OAuth2 #Scopes #Authorization #FastAPITutorial #BackendDevelopment #PythonTutorial #NileshTechnology
Video source:Youtube

Disclaimer:info@kdj.com

The information provided is not trading advice. kdj.com does not assume any responsibility for any investments made based on the information provided in this article. Cryptocurrencies are highly volatile and it is highly recommended that you invest with caution after thorough research!

If you believe that the content used on this website infringes your copyright, please contact us immediately (info@kdj.com) and we will delete it promptly.

Other videos published on Nov 16, 2026