API Key vs JWT vs OAuth: Authentication Fundamentals Quiz Quiz

Explore the essential differences, use cases, and best practices of API Keys, JWT, and OAuth with this quiz designed for understanding authentication methods in modern APIs. Sharpen your knowledge on secure API integration, token management, and the strengths of each approach.

  1. Identifying an API Key

    Which of the following is typically considered a simple, static string used for authenticating requests between a client and an API?

    1. API Key
    2. Cookie Token
    3. OAuth
    4. JWT

    Explanation: API Keys are usually simple, unique strings shared between client and server for basic authentication. JWTs are structured tokens with payloads, while OAuth is an authorization protocol using tokens. Cookie Tokens refer to session authentication rather than API Keys.

  2. Understanding JWT Content

    Which authentication method packages user claims such as roles and expiration time within a signed token passed to the server?

    1. HOTP
    2. JWT
    3. API Key
    4. OAuth

    Explanation: JWT (JSON Web Token) includes claims about the user, such as their role or token expiry, inside the token itself. API Keys do not have embedded claims. OAuth is mostly an authorization framework, not a token format. HOTP is a type of one-time password, not used for embedding claims.

  3. OAuth Protocol Purpose

    What is the primary purpose of OAuth in modern applications?

    1. Allowing third-party apps limited access without sharing user credentials
    2. Authenticating users with biometric data
    3. Storing user passwords securely
    4. Encrypting messages between servers

    Explanation: OAuth is designed to grant limited permissions to third-party applications without exposing user credentials, enhancing security and control. Encrypting messages is not OAuth's main role. OAuth does not store passwords nor does it handle biometric authentication directly.

  4. Revoking Access Quickly

    For which authentication method is revoking access typically as simple as removing a static value from a database?

    1. HOTP
    2. JWT
    3. OAuth
    4. API Key

    Explanation: Revoking an API Key involves deleting or disabling it on the server, which immediately blocks access. JWTs often remain valid until they expire, making revocation less straightforward. OAuth tokens may be revocable but usually require more complex logic, and HOTP is unrelated to API access control.

  5. Best for Mobile-Client Statelessness

    Which option provides a stateless way to authenticate users in single-page and mobile applications, with client-side storage and self-contained payloads?

    1. SSO
    2. API Key
    3. OAuth
    4. JWT

    Explanation: JWTs are stateless and self-contained, allowing clients to manage authentication without server-side session storage. API Keys do not encapsulate user data. OAuth may use JWTs but is itself an authorization protocol. SSO (Single Sign-On) is a sign-in process, not a token type.

  6. Which Represent Credentials vs Authorization

    When comparing API Key, JWT, and OAuth, which one is specifically a protocol for delegating permissions, not a type of credential?

    1. JWT
    2. SSO
    3. OAuth
    4. API Key

    Explanation: OAuth defines flows for delegating permissions to applications, not a credential itself. JWT and API Keys are both credential formats, though JWT can be used within OAuth. SSO is another authentication method, not a delegation protocol.

  7. Best Practice for Open/Public APIs

    Which authentication method is often used for simple, server-to-server access in scenarios where user identity is not required?

    1. SAML
    2. API Key
    3. JWT
    4. OAuth

    Explanation: API Keys are suitable for basic authentication between trusted systems without user context. OAuth is overkill for simple, non-user scenarios. JWTs can be used but are better suited to user-based claims. SAML is primarily used for federated identity, not API authentication.

  8. Short-Lived Vs Long-Lived Credentials

    Which statement is true regarding token lifespan in typical JWT-based APIs?

    1. JWTs are valid forever and always need manual refresh
    2. JWTs are commonly short-lived and cannot be revoked before expiry
    3. JWTs encrypt passwords for secure transmission
    4. JWTs are physical devices used for login

    Explanation: JWTs usually expire quickly to limit risks if compromised and are often not revocable except by waiting for expiry. They are not permanent, not physical objects, nor intended for password encryption.

  9. Which Provides Access Scopes

    In which authentication approach can a client request only certain permissions, such as read-only access to user data, following protocol-defined scopes?

    1. OAuth
    2. JWT
    3. MAG
    4. API Key

    Explanation: OAuth allows clients to specify and receive scopes for limited actions, which is controlled through the OAuth protocol. API Keys do not natively support scopes. JWT can be part of an OAuth flow but does not define scopes itself. MAG is not an authentication protocol.

  10. Securing Sensitive Operations

    Which method is generally less secure for sensitive user operations due to potential easy exposure and lack of user context?

    1. API Key
    2. OAuth
    3. HMAC
    4. JWT

    Explanation: API Keys can be compromised if exposed in code or URLs and do not tie directly to user context, making them weaker for sensitive tasks. OAuth and JWT can provide user-specific authentication, and HMAC is a signing method, not a standalone authentication system.