0
0
Rest APIprogramming~20 mins

OAuth 2.0 overview in Rest API - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
OAuth 2.0 Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What is the primary purpose of OAuth 2.0?

OAuth 2.0 is widely used in web applications. What is its main goal?

ATo provide a database for storing user credentials securely
BTo encrypt all data sent between client and server
CTo allow users to share their private resources stored on one site with another site without sharing credentials
DTo replace passwords with biometric authentication
Attempts:
2 left
💡 Hint

Think about how apps let you log in using accounts from other services without giving your password.

Predict Output
intermediate
2:00remaining
What is the output of this OAuth 2.0 token request response?

Given this JSON response from an OAuth 2.0 token endpoint, what is the value of the expires_in field?

Rest API
{
  "access_token": "abc123xyz",
  "token_type": "Bearer",
  "expires_in": 3600,
  "refresh_token": "def456uvw"
}
A3600
B"Bearer"
C"abc123xyz"
D"def456uvw"
Attempts:
2 left
💡 Hint

Look for the field that tells how long the access token is valid in seconds.

🔧 Debug
advanced
3:00remaining
Why does this OAuth 2.0 authorization code flow fail?

Consider this simplified OAuth 2.0 authorization code flow snippet. Why does it fail to obtain an access token?

POST /token HTTP/1.1
Host: auth.example.com
Content-Type: application/x-www-form-urlencoded

client_id=abc&redirect_uri=https://app.example.com/callback&code=xyz123
AThe <code>code</code> parameter is invalid because it is not URL encoded
BThe <code>redirect_uri</code> should not be included in the token request
CIncorrect HTTP method; should be GET instead of POST
DMissing <code>client_secret</code> parameter in the token request
Attempts:
2 left
💡 Hint

Think about what the authorization server needs to verify the client identity during token exchange.

📝 Syntax
advanced
2:00remaining
Which option correctly represents a valid OAuth 2.0 Bearer token HTTP header?

Choose the correct syntax for sending an OAuth 2.0 Bearer token in an HTTP request header.

AAuthorization: Bearer abc123xyz
BAuth: Bearer abc123xyz
CAuthorization: Token abc123xyz
DBearer: Authorization abc123xyz
Attempts:
2 left
💡 Hint

The standard header name and scheme must be used exactly.

🚀 Application
expert
3:00remaining
How many scopes are granted in this OAuth 2.0 access token response?

Given this OAuth 2.0 token response, how many scopes does the access token have?

{
  "access_token": "token123",
  "token_type": "Bearer",
  "expires_in": 1800,
  "scope": "read write delete"
}
A1
B3
C0
D4
Attempts:
2 left
💡 Hint

Count the number of space-separated words in the scope string.