Bird
0
0

Consider this code snippet for an API call:

medium📝 Predict Output Q13 of 15
Rest API - Authentication and Authorization
Consider this code snippet for an API call:
fetch('https://api.example.com/data', {
  headers: { 'Authorization': 'Bearer abc123' }
})
.then(response => response.json())
.then(data => console.log(data));
What is the main purpose of the 'Authorization' header here?
ATo provide a token proving the caller's identity.
BTo encrypt the data sent to the API.
CTo set the API response timeout.
DTo specify the data format expected.
Step-by-Step Solution
Solution:
  1. Step 1: Understand the 'Authorization' header role

    The 'Authorization' header carries credentials like tokens to prove who is calling the API.
  2. Step 2: Match the header purpose with options

    To provide a token proving the caller's identity. correctly states it provides a token for identity verification. Other options describe unrelated functions.
  3. Final Answer:

    To provide a token proving the caller's identity. -> Option A
  4. Quick Check:

    Authorization header = token for identity [OK]
Quick Trick: Authorization header carries tokens for access [OK]
Common Mistakes:
  • Confusing authorization with data format
  • Thinking it sets timeout
  • Assuming it encrypts data

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes