Courseiva
200-901Chapter 6 of 18Objective 1.2

API Authentication: API Keys, Basic Auth, and OAuth2

API authentication is the system that controls who gets access to an API — it is the digital bouncer at the door of your code. For the DevNet Associate 200-901 exam, you must understand the three most common methods: API keys, Basic Authentication, and the OAuth 2.0 framework, because they appear across Cisco's own APIs and in the wider networking ecosystem.

12 min read
Intermediate
Updated Jul 23, 2026
Reviewed by Johnson Ajibi· Senior Network & Security Engineer · MSc IT Security

A simple way to picture API Authentication: API Keys, Basic Auth, and OAuth2

The Specific Food Truck Event Analogy

You go to a food truck event with different trucks serving lunch, but first you need a way to get food from each one. This leads to three different methods of dealing with the vendors, each of which maps directly to an API authentication method.

First, you find a taco truck that asks for a membership card with a barcode. You hand over the card, they scan it, and they instantly know who you are and what meal plan you bought. This is an API key — a single, simple token you send with every request that identifies you and grants access without any passwords. It is the easiest method, but if someone steals your card, they can use it forever.

Next, you try a hot dog stand. The vendor asks, "What is your name and date of birth?" You answer, and they check a paper list. This is Basic Authentication — you send your username and password (encoded but not encrypted) with every request. It is simple, but like shouting your password across a crowded lot, it is vulnerable.

Finally, you want a burger from a truck that uses a special wristband system. You first go to the main booth, show your ID, and get a colour-coded wristband that works for sixty minutes. You then flash the wristband at the burger truck without showing your ID again. This is OAuth 2.0 — you get a temporary token from an authorisation server (the booth) and then present it to the resource server (the truck). The truck never sees your personal details, and the wristband expires, limiting damage if lost.

How It Actually Works

An API is an Application Programming Interface — it is a set of rules that lets one piece of software talk to another. For example, when your weather app asks a remote server for today's forecast, it does so through an API. But the server needs to know who is asking and whether they are allowed to get the data. That is what authentication does: it proves your identity to the API.

Let us start with the simplest method: API Keys. An API key is a long, unique string of characters that the API provider gives to you, the developer. Think of it like a password that is shared between two machines. When your app makes a request to the API, it includes this key, often in the URL or in a special part of the request called a header. The server checks the key against its database. If it matches, the request is allowed. API keys are easy to implement and fast, but they have drawbacks. Because the key is the only thing used for identification, if it is exposed — say, you accidentally upload it to a public code repository like GitHub — anyone can use it. API keys are also usually static: they do not expire unless you manually rotate them. This means a compromised key stays compromised until someone changes it.

Next is Basic Authentication, often called Basic Auth. In this method, your app sends a username and password with every single API request. But it does not send them as plain text. Instead, it combines them into a single string in the format "username:password" and then converts that string using a method called Base64 encoding. For example, if your username is "alice" and your password is "secret123", the combined string "alice:secret123" becomes "YWxpY2U6c2VjcmV0MTIz". This encoding is NOT encryption — it is just a way to represent binary data in text. Anyone who intercepts that encoded string can decode it instantly with any Base64 decoder tool. The real world uses Basic Auth only over HTTPS, because HTTPS encrypts the entire communication channel, protecting the encoded credentials during transit. Even so, Basic Auth is considered weak for modern applications because the credentials are sent on every request, increasing exposure risk. The server must also store the passwords (ideally as hashes), which creates a management burden.

The most sophisticated method is OAuth 2.0 (Open Authorisation 2.0). OAuth 2.0 is not a single technique but a framework — a set of rules that allows one service to grant limited access to another service on behalf of a user, without the user revealing their password directly. It is the system behind "Sign in with Google" or "Sign in with Facebook." Let us break down its key components. First, there is the Resource Owner — usually the end user who owns the data. Second, the Client — the application that wants access to that data. Third, the Authorisation Server — the service that issues tokens after authenticating the user. Fourth, the Resource Server — the API that holds the actual data.

The flow works like this. The client application redirects the user to the authorisation server's login page. The user authenticates (logs in) and then is shown a consent screen that says, "This app wants to access your contacts. Allow or deny?" If the user approves, the authorisation server issues an authorisation grant to the client. The client then exchanges that grant for an access token — a temporary, opaque string that acts as a key to the resource server. The client includes this access token in every API request to the resource server, which validates the token without ever seeing the user's password. The access token typically expires after a short time (e.g., sixty minutes), and the client may also receive a refresh token that allows it to get new access tokens without bothering the user again. This design limits the damage if a token is stolen — the token expires, and the user can revoke it from the authorisation server.

The OAuth 2.0 framework defines several grant types (flows) for different scenarios. The Authorisation Code flow is the most secure for web apps. The Implicit flow is simpler but less secure, used for client-side apps like JavaScript in a browser. The Client Credentials flow is for server-to-server communication where there is no user involved — the client itself is the resource owner. The Resource Owner Password Credentials flow uses a username and password directly (like Basic Auth but within the OAuth framework) and is generally discouraged.

Why does this matter for the 200-901 exam? Cisco APIs, such as those for managing Meraki or Webex, use these methods. You will need to know when to use each, the security trade-offs, and how to implement them in simple REST API calls. API keys are common for low-risk public endpoints. Basic Auth is sometimes used in legacy systems or quick prototypes. OAuth 2.0 is the modern standard for any application that handles user data or requires fine-grained permissions.

Flowchart showing the three API authentication methods (API Key, Basic Auth, OAuth 2.0) and how credentials or tokens are exchanged between the client, authorisation server, and resource server.

Walk-Through

1

1. Decide the authentication method

For a given API, you first decide whether to use an API key, Basic Auth, or OAuth 2.0. An API key suits simple public data, Basic Auth for legacy systems, and OAuth 2.0 for user-specific or scoped access. This choice determines all subsequent steps.

2

2. Obtain credentials or register the client

For API keys, get the key from the API provider's dashboard. For Basic Auth, create a username and password pair. For OAuth 2.0, register your application as a client with the authorisation server to receive a Client ID and Client Secret.

3

3. Initiate the request with credentials

For API keys, include the key in a custom header (e.g., X-API-Key) or query parameter. For Basic Auth, construct the Base64-encoded string and put it in the Authorization header. For OAuth 2.0, the client redirects the user to the authorisation server for login and consent.

4

4. Handle the authorisation response

For API keys and Basic Auth, the server immediately validates and responds. For OAuth 2.0, the authorisation server returns an authorisation code to the client, which the client exchanges for an access token (and possibly a refresh token) by sending the code, Client ID, and Client Secret to a token endpoint.

5

5. Use the access token for API calls

With the access token (or the API key for simpler methods), include it in the Authorization header as 'Bearer <token>' for OAuth or as configured for keys. The resource server validates the token and returns the requested data. For OAuth, when the token expires, the client uses the refresh token to get a new access token without user involvement.

6

6. Revoke or rotate credentials when needed

If a key or token is compromised, revoke it from the API provider's dashboard (API keys) or from the authorisation server (OAuth tokens). Regularly rotate API keys and consider token expiration intervals to limit exposure. This step is crucial for maintaining security over time.

What This Looks Like on the Job

Imagine you work as a network administrator at a medium-sized company that uses Cisco Meraki for wireless networking and Webex for team collaboration. Your manager asks you to write a script that automatically pulls usage data from the Meraki dashboard and posts a daily summary to a Webex team room. This is a perfect scenario to understand these authentication methods in practice.

First, you need to access the Meraki API. You log in to the Meraki dashboard, navigate to the API access section, and generate an API key — a long string like '6b4b7f1a2c3d4e5f6a7b8c9d0e1f2abc'. You copy this key carefully and store it in a secure environment variable, never in the script's code. Your script then sends a GET request to the Meraki API endpoint, including this key in the request header as X-Cisco-Meraki-API-Key: your-key-here. The Meraki server checks the key and returns the usage data in JSON format. This works well because the script is simply pulling data that your organisation owns — there is no user-specific data involved. The key grants broad access, so you must guard it fiercely.

Next, you need to post the summary to a Webex team room. Webex uses OAuth 2.0 because you are asking Webex to act on behalf of a user (you) to post messages. You cannot simply use an API key because Webex needs to know who is posting and ensure they have permission. Here is the step-by-step process you follow:

You register your script as an OAuth client in the Webex Developer portal. You get a Client ID and Client Secret — two unique strings that identify your application to Webex's authorisation server.

Your script asks you to visit a URL that leads to Webex's login page. You log in with your Webex credentials.

Webex shows a consent screen: "The script 'Daily Summary Bot' wants to post messages to your team rooms. Allow?" You click Allow.

Webex redirects you back to your script with an authorisation code in the URL.

Your script sends this code plus the Client ID and Client Secret to the Webex token endpoint. The endpoint returns an access token (e.g., 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...') and a refresh token.

Your script includes the access token in the HTTP header Authorization: Bearer <token> when it posts the summary to the room.

The access token expires after one hour. Your script uses the refresh token daily to get a fresh access token without requiring you to log in again.

In this real scenario, you used both API keys (for Meraki) and OAuth 2.0 (for Webex) in the same project. You never used Basic Auth because it is too risky for a production script that runs unattended — if the username and password were ever exposed, an attacker could control everything. The OAuth 2.0 flow gave you granular control: the script only had permission to post messages, not to read private files or delete rooms. If you needed to revoke the script's access later, you could revoke the OAuth grant from the Webex portal without changing any user passwords. This is the practical value of these authentication methods: they balance security, convenience, and control in a way that matches the needs of the task.

How 200-901 Actually Tests This

The 200-901 DevNet Associate exam tests objective 1.2 — 'Describe API authentication methods and tokens' — through scenario-based questions that evaluate your understanding of when and why to use each method. You will not be asked to implement OAuth 2.0 from scratch in an exam. Instead, you will need to identify the correct method for a given situation, recognise the parts of a token flow, and spot common security flaws.

Here are the specific concepts they love to test:

The difference between authentication and authorisation. Authentication verifies who you are (e.g., logging in with a password). Authorisation determines what you are allowed to do (e.g., reading a file or deleting a user). OAuth 2.0 primarily handles authorisation, not authentication, though it often works alongside an identity provider.

The components of OAuth 2.0: resource owner, client, authorisation server, resource server. You must be able to label these in a diagram or flow.

The four main grant types: Authorisation Code, Implicit, Client Credentials, and Resource Owner Password Credentials. You should know which is most secure for a web app (Authorisation Code), which is used for server-to-server (Client Credentials), and why Implicit is deprecated for modern apps.

The concept of a Bearer Token — a token that grants access to the bearer (anyone who holds it). This is the most common type in OAuth 2.0. The token is like a bearer bond: whoever has it can use it.

The difference between access tokens and refresh tokens. Access tokens are short-lived and presented to the resource server. Refresh tokens are long-lived and used only to get new access tokens from the authorisation server.

How to include authentication in an HTTP request. API keys often go in a custom header (e.g., X-API-Key) or as a query parameter. Basic Auth uses the Authorization: Basic <base64> header. OAuth 2.0 uses Authorization: Bearer <token>.

Why Basic Auth is considered weak: it sends credentials on every request, uses simple Base64 encoding (not encryption), and requires the server to store passwords.

Common exam traps include:

Confusing Base64 encoding with encryption. A question might describe a method that sends a 'secret encoded token' and suggest it is secure because it is 'encoded.' Remember: encoding is reversible without a key; encryption is not. This trap is classic on the exam.

Mixing up the roles. For example, the resource server and authorisation server are often the same server in simple implementations, but in a distributed OAuth system they are separate. The exam might present a scenario where they are separate and expect you to know that.

Thinking API keys are a form of OAuth. They are not. API keys are a simpler, standalone method. OAuth is a framework that manages tokens for delegated access.

Assuming that 'Bearer Token' means the token contains user information. A bearer token is just a random string. The token does not encode the user's identity; the server looks it up.

The exam also tests your ability to read the typical flow. For instance, a question might provide a step-by-step list and ask you to identify which step is missing or incorrect in an OAuth Authorisation Code flow. They may show a snippet of an HTTP request and ask which authentication method is being used based on the header. For example, Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ= is definitely Basic Auth. Authorization: Bearer eyJraWQiOiIxZ... is OAuth 2.0. No Authorization header with an API key indicates a custom method.

To prepare, memorise the definitions from the Cisco glossary for 'API key', 'Basic Authentication', 'OAuth 2.0', 'bearer token', 'refresh token', and 'authorisation code'. Practise reading HTTP requests and identifying the auth method from headers. Understand the security considerations for each method and be ready to recommend one over another for a given scenario, such as a mobile app versus a server-side script.

Key Takeaways

API keys are simple, static tokens that must be kept secret and are suitable for low-risk, server-to-server scenarios.

Basic Authentication sends a username and password with every request, encoded in Base64 but not encrypted, and should only be used over HTTPS.

OAuth 2.0 is an authorisation framework, not an authentication protocol, that delegates access using temporary tokens with scopes and expiration.

An OAuth 2.0 access token is a bearer token, meaning anyone who holds it can use it, so it must be transmitted over secure channels.

Refresh tokens are long-lived credentials used only to get new access tokens from the authorisation server, never the resource server.

The Authorisation Code grant type is the most secure OAuth 2.0 flow for web applications because it keeps the client secret away from the browser.

Easy to Mix Up

These come up on the exam all the time. Here's how to tell them apart.

API Key

Typically static and does not expire until manually rotated

Sent in API calls with a simple custom header or query parameter

Grants broad access based on the key itself, not per-user scopes

OAuth 2.0 Access Token

Short-lived by design (e.g., expires in 60 minutes)

Sent in the Authorization header as 'Bearer <token>'

Allows fine-grained scopes on a per-user basis

Basic Authentication

Sends username and password as a Base64-encoded string in every request

Does not involve a separate authorisation server or token endpoint

Requires the server to store passwords (or hashes)

OAuth 2.0 Resource Owner Password Credentials

Uses the same username and password input, but exchanges them once for an access token

Involves an authorisation server that issues tokens with expiration

Access token is sent in subsequent requests; password is not repeated

Authorisation Code Grant (OAuth 2.0)

Requires a client secret kept on the server side

Access token is obtained after two exchanges: code, then token

Considered the most secure flow for web applications

Implicit Grant (OAuth 2.0, deprecated)

No client secret used; token returned in the URL fragment

Only one step: user approves, and token is directly sent back to the client

Deprecated due to security risks from token leakage in URLs

Client Credentials Grant (OAuth 2.0)

Used for server-to-server communication with no user involved

The client authenticates itself using its Client ID and Secret to get a token

Token scope is fixed to what the client application is allowed to do

Authorisation Code Grant (OAuth 2.0)

Used when a user (resource owner) is involved and must grant consent

The user authenticates to the authorisation server and approves a scope

Token scope can vary per user based on consent

Watch Out for These

Mistake

An API key is the same as an OAuth 2.0 bearer token.

Correct

An API key is a simple, static identifier that you send with every request, while an OAuth 2.0 bearer token is a temporary, scoped token obtained through an authorisation flow and can be refreshed.

Both are strings sent in API requests, so beginners often lump them together. However, their lifecycle, security model, and purpose differ significantly.

Mistake

Basic Authentication is secure because it uses Base64 encoding.

Correct

Base64 encoding is not encryption — it is a reversible format that anyone can decode. Basic Auth is only secure if used over HTTPS, and even then it exposes credentials on every request.

The word 'encoding' sounds technical and 'safe' to a beginner, but it is simply a way to convert binary data to text. Without understanding the difference between encoding and encryption, beginners assume it protects the credentials.

Mistake

OAuth 2.0 is an authentication protocol.

Correct

OAuth 2.0 is an authorisation framework. It grants limited access to resources on behalf of a user but does not directly authenticate the user. In practice, it is often combined with OpenID Connect for authentication.

The name 'Open Authorisation' suggests it is about access, but many courses and tutorials blur the line. Beginners hear 'sign in with Google' and assume OAuth is for logging in, missing the nuance.

Mistake

An OAuth 2.0 refresh token can be used to access the resource server directly.

Correct

A refresh token is only used to obtain new access tokens from the authorisation server. It should never be sent to the resource server. Access tokens are the only tokens that go to the resource server.

Both tokens look similar (long random strings), so beginners think they are interchangeable. The exam often tests the distinct roles of each token type.

Mistake

If you have an API key, you do not need HTTPS.

Correct

HTTPS is still required because API keys are sent over the network. Without HTTPS, the key can be intercepted in plain text, and anyone can reuse it.

Some beginners think the key itself is the security, but keys are just credentials. Network security (HTTPS) is a separate layer that protects credentials in transit.

Mistake

The Resource Owner Password Credentials grant type is the most secure OAuth flow.

Correct

This grant type is actually the least secure of the main flows because the client directly handles the user's password, increasing exposure risk. It is discouraged for modern applications.

It looks similar to a simple login form, which feels familiar and 'safe' to a beginner, but it violates the core OAuth principle of not sharing passwords with third parties.

Do You Actually Know This?

Reveal each answer, then mark whether you got it right. Score 60%+ to unlock the next chapter.

Frequently Asked Questions

Is Base64 encoding secure for passwords in Basic Auth?

No, Base64 is not encryption — it is a reversible encoding method. Anyone who intercepts the request can decode it instantly. Basic Auth is only safe when used over HTTPS, which encrypts the entire channel.

Can I use an API key with OAuth 2.0?

No, they are separate methods. API keys are a simple static credential, while OAuth 2.0 uses tokens obtained through an authorisation flow. Some APIs support both, but you choose one method per request.

What is the difference between an access token and a refresh token?

An access token is short-lived (often minutes or hours) and is sent to the resource server to access data. A refresh token is longer-lived and is sent only to the authorisation server to obtain new access tokens without requiring the user to log in again.

Why is the Implicit grant type deprecated?

The Implicit grant was designed for single-page apps and returned the access token directly in the URL, making it vulnerable to interception and leakage. The current best practice is to use the Authorisation Code flow with PKCE, which is more secure.

Do I need to handle tokens manually in OAuth 2.0?

In many modern frameworks and libraries, token management (including refreshing) is handled automatically. However, for the 200-901 exam, you must understand the underlying steps, such as where tokens are sent and how they are validated.

Can a bearer token be used by anyone who finds it?

Yes, that is why it is called a bearer token — whoever holds it can use it. This is why access tokens must be transmitted over HTTPS, stored securely, and given short expiration times.

Terms Worth Knowing

Keep going

You've finished API Authentication: API Keys, Basic Auth, and OAuth2. Continue through the 200-901 study guide to build a complete picture of the exam.

Done with this chapter?