Skip to content

Latest commit

 

History

History
29 lines (15 loc) · 1.13 KB

interview-questions.md

File metadata and controls

29 lines (15 loc) · 1.13 KB

What's the difference between Tokens and API keys?

We use API keys and tokens for authentication and authorization.

But they serve different purposes and have distinct characteristics.

Tokens (like JWT - JSON Web Tokens):

Carries user context and permissions for authentication and authorization.

Encoded with a user ID, permissions, and expiration time, often in JWT format.

Critical for user-specific access, like accessing a user's profile data in an e-commerce platform.

It is issued by an authentication server after user login and contains user-specific information.

API Key:

Primarily for identifying the application or the consumer making the API call.

They are long strings we pass in the header or as a query parameter in the API request.

You use API keys when access does not involve user context. For example, accessing a public API or service-to-service communication.

They are long-lived and created through the API provider's platform or admin console.

Links: