OAuth2 is a way for apps to get permission to access your info on another app without sharing your password. It's like giving a valet key to your car instead of the full key.
Click to reveal answer
beginner
Name the four main roles in OAuth2.
The four main roles are: Resource Owner (you), Client (the app asking for access), Authorization Server (checks permission), and Resource Server (holds the data).
Click to reveal answer
beginner
What is an access token in OAuth2?
An access token is like a temporary pass that the client app uses to access your data from the resource server after you say yes.
Click to reveal answer
intermediate
How does OAuth2 improve security compared to sharing passwords?
OAuth2 lets apps access only what you allow without sharing your password. If the app is bad, your password stays safe and you can revoke access anytime.
Click to reveal answer
beginner
In Flask, which library helps implement OAuth2 easily?
Flask-Dance is a popular library that helps Flask apps use OAuth2 to connect with services like Google or GitHub easily.
Click to reveal answer
Which OAuth2 role is responsible for holding the user's data?
AResource Server
BClient
CAuthorization Server
DResource Owner
✗ Incorrect
The Resource Server holds the user's data and responds to requests with a valid access token.
What does the client receive after the user grants permission in OAuth2?
AAccess Token
BPassword
CRefresh Token
DAuthorization Code
✗ Incorrect
The client receives an access token to access the user's data on the resource server.
Which OAuth2 role verifies the user's permission?
AClient
BResource Owner
CResource Server
DAuthorization Server
✗ Incorrect
The Authorization Server checks if the user has given permission to the client.
Why is OAuth2 safer than sharing passwords?
AIt requires no user permission
BIt uses temporary tokens instead of passwords
CIt shares passwords securely
DIt stores passwords in the client app
✗ Incorrect
OAuth2 uses temporary tokens, so passwords are never shared with the client app.
Which Flask library helps implement OAuth2 easily?
AFlask-SQLAlchemy
BFlask-Login
CFlask-Dance
DFlask-Mail
✗ Incorrect
Flask-Dance is designed to help Flask apps use OAuth2 with external services.
Explain the main roles in OAuth2 and their responsibilities.
Think about who owns data, who asks for it, and who controls access.
You got /4 concepts.
Describe how OAuth2 improves security when apps need access to your data.
Compare it to giving a valet key instead of your full car key.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of OAuth2 in a Flask application?
easy
A. Store user passwords securely in the Flask app database
B. Allow users to log in using external services without sharing passwords
C. Encrypt all data sent between client and server
D. Automatically create user accounts without permission
Solution
Step 1: Understand OAuth2 role
OAuth2 lets apps use other services for login without handling user passwords directly.
Step 2: Identify correct purpose in Flask context
Flask apps use OAuth2 to let users sign in via external providers safely.
Final Answer:
Allow users to log in using external services without sharing passwords -> Option B
Quick Check:
OAuth2 = external login without password sharing [OK]
Hint: OAuth2 means login without storing passwords [OK]
Common Mistakes:
Thinking OAuth2 stores passwords
Confusing OAuth2 with encryption
Assuming OAuth2 creates accounts automatically
2. Which Flask extension is commonly used to simplify OAuth2 integration?
easy
A. Flask-WTF
B. Flask-SQLAlchemy
C. Authlib
D. Flask-Mail
Solution
Step 1: Recall Flask extensions for OAuth2
Authlib is a popular Flask extension designed to handle OAuth2 easily.
Step 2: Eliminate unrelated extensions
Flask-SQLAlchemy manages databases, Flask-WTF handles forms, Flask-Mail sends emails, so they don't handle OAuth2.
Final Answer:
Authlib -> Option C
Quick Check:
OAuth2 in Flask = Authlib [OK]
Hint: Authlib is for OAuth2 in Flask [OK]
Common Mistakes:
Choosing Flask-SQLAlchemy for OAuth2
Confusing form or mail extensions with OAuth2
Not knowing Authlib's purpose
3. Given this Flask OAuth2 code snippet, what will print(user_info) output after successful login?
A. Missing parentheses when calling authorize_access_token
B. Using 'userinfo' instead of 'user_info' endpoint
C. Returning JSON directly causes syntax error
D. No redirect URI specified in authorize route
Solution
Step 1: Check method call syntax
The code uses google.authorize_access_token without parentheses, so it references the method, not calls it.
Step 2: Understand effect of missing parentheses
Without calling the method, token is a function object, causing errors later.
Final Answer:
Missing parentheses when calling authorize_access_token -> Option A
Quick Check:
Method call needs () [OK]
Hint: Always add () to call methods [OK]
Common Mistakes:
Forgetting parentheses on method calls
Confusing endpoint names
Assuming JSON return causes error
5. You want your Flask app to request only the user's email and profile during OAuth2 login with Google. Which scope value should you use when registering the OAuth client?
hard
A. 'openid email profile'
B. 'read write'
C. 'user:email user:profile'
D. 'email profile openid offline_access'
Solution
Step 1: Identify correct OAuth2 scopes for Google
Google uses 'openid email profile' scopes to request user's email and profile info.
Step 2: Eliminate incorrect scopes
'read write' is generic, 'user:email user:profile' is GitHub style, 'offline_access' requests refresh tokens, not needed here.
Final Answer:
'openid email profile' -> Option A
Quick Check:
Google OAuth2 scopes for email/profile = 'openid email profile' [OK]
Hint: Use 'openid email profile' for Google OAuth2 scopes [OK]
Common Mistakes:
Using GitHub or generic scopes
Adding unnecessary offline_access scope
Confusing scope syntax
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.