<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ayyoob Ajward on Medium]]></title>
        <description><![CDATA[Stories by Ayyoob Ajward on Medium]]></description>
        <link>https://medium.com/@ajwardayyoob?source=rss-d24d94c5f383------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*zOnSjP0vd5O5fEQwBv07pQ.png</url>
            <title>Stories by Ayyoob Ajward on Medium</title>
            <link>https://medium.com/@ajwardayyoob?source=rss-d24d94c5f383------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 03:23:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ajwardayyoob/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[AuthN & AuthZ for Dummies Series — Part 5: Client Credential Flow]]></title>
            <link>https://medium.com/@ajwardayyoob/authn-authz-for-dummies-series-part-5-client-credential-flow-ba055a23b18f?source=rss-d24d94c5f383------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba055a23b18f</guid>
            <category><![CDATA[authorization]]></category>
            <category><![CDATA[oauth]]></category>
            <category><![CDATA[client-credentials-flow]]></category>
            <category><![CDATA[oauth2]]></category>
            <dc:creator><![CDATA[Ayyoob Ajward]]></dc:creator>
            <pubDate>Sat, 26 Apr 2025 15:32:30 GMT</pubDate>
            <atom:updated>2025-04-26T15:41:27.568Z</atom:updated>
            <content:encoded><![CDATA[<h3>AuthN &amp; AuthZ for Dummies Series — Part 5: Client Credential Flow</h3><blockquote><strong>Note</strong>: If you missed the earlier parts of this <strong>“AuthN &amp; AuthZ for Dummies”</strong> series, we’ve already covered a lot of important concepts — like what access tokens and refresh tokens are, how token validation works, and best practices around token lifetimes. Now, in Part 5, we’ll dive into the <strong>Client Credential Flow</strong>.</blockquote><p>The Client Credentials Flow is used for machine-to-machine authorization, where no human involvement is required. If you do need human involvement, you should use the <strong>Authorization Code Flow</strong> instead.</p><p>This method operates over the <strong>back-channel</strong>, as we’ve discussed earlier.</p><p>Compared to the Authorization Code Flow, the Client Credentials Flow involves fewer steps. Here’s how it works:</p><blockquote><strong>Note</strong>: When you register your application or service with the authorization server, you’ll get a <strong>client_id</strong> and a <strong>client_secret</strong>.</blockquote><blockquote><strong>- client_id</strong> is like your username — it can be publicly visible and isn’t sensitive.</blockquote><blockquote><strong>- client_secret</strong> is like your password — it should <strong>never</strong> be exposed publicly.</blockquote><blockquote>(If you want to see this for yourself, try registering an app in AWS Cognito — you’ll get both a client_id and a client_secret.</blockquote><p>In this flow, the client directly requests an access token from the authorization server. It’s like saying: <strong>“Hey, I need an access token to use the API. Here’s my </strong><strong>client_id and </strong><strong>client_secret.” </strong>The authorization server then responds: <strong>“Let me check... Yes, you’re already registered in our system. Here’s your access token.”</strong></p><p>That’s it — simple and direct. One key point to remember is that <strong>there is no refresh token</strong> in this flow.</p><p>Also, since this is just two machines talking to each other, <strong>you don’t need a UI at all</strong>.</p><p><strong>Examples where Client Credentials Flow is used:</strong></p><ul><li>Cron Jobs</li><li>Configuration Management Tools</li><li>GitHub Actions</li></ul><h4>How the Client Credentials Flow Works:</h4><p><strong>Step 1:</strong><br>The client sends a request to the Authorization Server, basically saying: <em>“Can I get an access token? Here’s my </em><strong><em>client_id</em></strong><em> and </em><strong><em>client_secret.</em></strong><em>”</em></p><p>By sending both the <strong>client_id</strong> and <strong>client_secret</strong>, the client is authenticating itself to the authorization server. Since this all happens over the <strong>backchannel</strong> (server-to-server communication), it’s safe to send the client_secret.</p><pre>POST /oauth2/token HTTP/1.1<br>Host: authorization-server.com<br><br>grant_type=client_credentials<br>&amp;client_id=YOUR_CLIENT_ID<br>&amp;client_secret=YOUR_CLIENT_SECRET</pre><p>You can see the grand type is : <strong>client_credentials</strong> it means this flow is client credential flow.</p><p><strong>Step 2:</strong><br>The <strong>Authorization Server</strong> checks if the provided client_id and client_secret are valid (i.e., the client is registered and trusted). If everything checks out, it responds with an <strong>access token</strong>.</p><p>Response to the request:</p><pre>{<br>  &quot;access_token&quot;: &quot;eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...&quot;,<br>  &quot;token_type&quot;: &quot;Bearer&quot;,<br>  &quot;expires_in&quot;: 3600<br>}</pre><p><strong>Step 3:</strong><br>The client then uses this <strong>access token</strong> to access the <strong>Resource Server</strong> by attaching it to the <strong>Authorization header</strong> of the API request.</p><pre>GET /api/data HTTP/1.1<br>Host: resource-server.com<br>Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...</pre><p>The <strong>Client Credentials Flow</strong> only works with <strong>confidential clients</strong>.</p><p>If you’re not familiar with what confidential clients are, feel free to check out my <a href="https://medium.com/@ajwardayyoob/authn-authz-for-dummies-series-part-3-back-channel-vs-front-channel-communication-caf4986206b7">previous blog post</a> where I explained it in more detail — or just give it a quick Google!</p><p>In short:</p><ul><li><strong>Confidential clients</strong> are applications that can <strong>securely authenticate</strong> with the authorization server. This means they are able to keep their registered <strong>client secret</strong> safe. Examples include backend services, server-side apps, or any app running in a secure environment.</li><li><strong>Public clients</strong>, on the other hand, are <strong>not able to securely store secrets</strong> — like apps running in browsers or on mobile devices. Since they can’t keep a client secret truly private, they’re not suitable for this flow.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba055a23b18f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AuthN & AuthZ for Dummies Series — Part 4: Access Token vs Refresh Token in OAuth2]]></title>
            <link>https://medium.com/@ajwardayyoob/authn-authz-for-dummies-series-part-4-access-token-vs-refresh-token-in-oauth2-05f5d8104421?source=rss-d24d94c5f383------2</link>
            <guid isPermaLink="false">https://medium.com/p/05f5d8104421</guid>
            <category><![CDATA[refresh-token]]></category>
            <category><![CDATA[oauth2]]></category>
            <category><![CDATA[jwt]]></category>
            <category><![CDATA[access-token]]></category>
            <category><![CDATA[jwt-token]]></category>
            <dc:creator><![CDATA[Ayyoob Ajward]]></dc:creator>
            <pubDate>Sat, 26 Apr 2025 13:04:19 GMT</pubDate>
            <atom:updated>2025-04-26T13:08:56.003Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>AuthN &amp; AuthZ for Dummies Series — Part 4: Access Token vs Refresh Token in OAuth2</strong></h3><blockquote><strong>Note</strong>: This is Part 4 of the “AuthN &amp; AuthZ for Dummies” series. If you’re new here, we’ve already covered the basics flows, and communication channels. Now it’s time to talk about token lifecycles and how refresh tokens help keep sessions alive.</blockquote><h3>What is an Access TOKEN 🔑?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/0*w0UzvePQsq6nz-cM.png" /><figcaption>Source: Oauth0.com</figcaption></figure><p>There’s no one specific structure for an access token — it can be anything, from a random string to a structured JSON Web Token (JWT).</p><p>There are basically two types of tokens</p><ul><li>Reference Token — Just a random string of characters that doesn’t mean anything by itself but points to something stored somewhere else.</li><li>Self-Contained Token — A structured token that actually carries some data inside it.</li></ul><p>You could implement reference tokens in a relational database by having a table for tokens — one column for the token itself and other columns for things like the user ID, token lifetime, and scopes.</p><p>You could also use a caching layer like Memcached or Redis. In that case, you generate a random string that becomes the cache key.</p><p>If it’s a self-contained token, it can hold data like the user info, which application it’s for, when it expires, when it was created, the scopes, the authorization server, last login time, and so on.</p><h4><strong>Which one should you use?</strong></h4><p>There are pros and cons to both. If your access token contains sensitive information, it’s better to go with a reference token. With reference tokens, nobody — not even the resource server or developers — can see the actual data; it’s just a random string.</p><p>If there’s no sensitive information, it’s better to go with a self-contained token. <em>Self-contained</em> doesn’t always mean JWT — it can be any format that carries meaningful information. But most systems prefer using JWTs.</p><p>Also, with self-contained tokens, you don’t need to maintain a token table in your database. The resource server doesn’t have to send the token back to the authorization server to validate it either — so you can save on network latency.</p><p>If you’re using JWTs, you don’t need any extra storage, because they can be validated directly.</p><p>The downside of JWTs, though, is that once they’re issued, there’s no way to revoke them — you just have to wait until they expire.</p><h4><strong>JWT Access Token Standard (OAuth2)</strong></h4><p>n OAuth2, there’s a standard for what fields should be included inside a JWT access token. Some fields are required, and others are optional.</p><p><strong>Required fields:</strong></p><ul><li><strong>iss: The issuer</strong> — who issued the token (usually the authorization server).</li><li><strong>exp: Expiration time</strong> — when the token will expire (in UNIX timestamp format).</li><li><strong>iat: Issued at </strong>— when the token was created (also in UNIX timestamp format).</li><li><strong>aud: Audience</strong> — the resource server(s) the token is intended for.</li><li><strong>sub: Subject </strong>— who the token is about.</li></ul><p>If a user is involved (like in authorization code flow), this would be the user’s identifier (usually just an opaque string, not something like a username or email).</p><p>If no user is involved (like in client credentials flow), this would be the client ID of the application.</p><ul><li><strong>client_id: The client ID</strong> of the application that requested and received the token.</li><li><strong>jti: JWT ID</strong> — a unique identifier for this token.</li></ul><p>The resource server can use this to detect if a token is being reused (to catch replay attacks).</p><p><strong>Optional fields:</strong></p><ul><li><strong>scope</strong>: The scopes or permissions associated with the token.</li><li><strong>auth_time</strong>: The time when the user last authenticated.</li><li><strong>Plus, you can add</strong> any custom properties depending on your system’s needs.</li></ul><h4><strong>Remote Token Introspection — How can an API check if a token is valid?</strong></h4><p>One way to validate a token is by sending a POST request to the authorization server with the token you want to check.</p><p>You make an HTTP POST request to the token introspection endpoint, passing the token value as a parameter (usually named token). Sometimes, the introspection endpoint requires authentication — you can handle that with machine-to-machine authentication, like using the client credentials flow.</p><p>When you send the request, you’ll get back a JSON response with at least one property: active, which is a boolean (true or false).</p><pre>{<br>  active: true<br>}</pre><ul><li>If active is true, the token is valid, and you might also get more details about it (like scopes, user info, etc.).</li><li>If active is false, the token is invalid for some reason, and again, you might get some extra information explaining why.</li></ul><p>The exact details you get back depend on the authorization server, because different servers can implement introspection responses a little differently.</p><h4>Local Token Validation</h4><p>In local token validation, there’s no network call to the authorization server. Instead, the resource server validates the token by itself. You can use libraries for this, or if you want to do it manually, here’s the basic process:</p><p>A JSON Web Token (JWT) has three parts: the header, the payload, and the signature. The header and payload are Base64-encoded JSON.</p><p>First, you decode them to see what’s inside the header. The header tells you which algorithm was used to sign the token, and it might also include a kid (Key ID) to indicate which signing key was used.</p><p>Example of a decoded header:</p><pre>{<br>  &quot;alg&quot;: &quot;RS256&quot;,<br>  &quot;typ&quot;: &quot;JWT&quot;,<br>  &quot;kid&quot;: &quot;abc123&quot;<br>}</pre><p>Example of a decoded payload:</p><pre>{<br>  &quot;iss&quot;: &quot;https://your-auth-server.com/&quot;,<br>  &quot;sub&quot;: &quot;1234567890&quot;,<br>  &quot;aud&quot;: &quot;your-client-id&quot;,<br>  &quot;exp&quot;: 1713667200,<br>  &quot;iat&quot;: 1713663600,<br>  &quot;scope&quot;: &quot;openid profile email&quot;,<br>  &quot;email&quot;: &quot;user@example.com&quot;,<br>  &quot;preferred_username&quot;: &quot;johndoe&quot;,<br>  &quot;given_name&quot;: &quot;John&quot;,<br>  &quot;family_name&quot;: &quot;Doe&quot;<br>}</pre><p><strong>Important:</strong><br> The JWT specification clearly says that the none algorithm must <em>not</em> be used. If you decode the token and see this:</p><pre>{<br>  &quot;alg&quot;: &quot;none&quot;<br>}</pre><p>You should immediately invalidate the token <em>before</em> even reading the payload. Accepting a token with alg: none can open up a lot of security vulnerabilities.</p><p>OAuth servers expose a metadata URL where you can find important information about their endpoints.<br>Example: <a href="https://authorization-server.com/.well-known/oauth-authorization-server">https://authorization-server.com/.well-known/oauth-authorization-server</a></p><p>When you fetch that URL, you’ll get back a JSON object like this:</p><pre>{<br>  &quot;issuer&quot;: &quot;https://your-auth-server.com&quot;,<br>  &quot;authorization_endpoint&quot;: &quot;https://your-auth-server.com/oauth2/authorize&quot;,<br>  &quot;token_endpoint&quot;: &quot;https://your-auth-server.com/oauth2/token&quot;,<br>  &quot;userinfo_endpoint&quot;: &quot;https://your-auth-server.com/oauth2/userinfo&quot;,<br>  &quot;jwks_uri&quot;: &quot;https://your-auth-server.com/.well-known/jwks.json&quot;,<br>  &quot;response_types_supported&quot;: [<br>    &quot;code&quot;,<br>    &quot;token&quot;,<br>    &quot;id_token&quot;,<br>    &quot;code token&quot;,<br>    &quot;code id_token&quot;,<br>    &quot;token id_token&quot;,<br>    &quot;code token id_token&quot;<br>  ],<br>  &quot;subject_types_supported&quot;: [&quot;public&quot;],<br>  &quot;id_token_signing_alg_values_supported&quot;: [&quot;RS256&quot;],<br>  &quot;scopes_supported&quot;: [&quot;openid&quot;, &quot;profile&quot;, &quot;email&quot;, &quot;offline_access&quot;],<br>  &quot;token_endpoint_auth_methods_supported&quot;: [<br>    &quot;client_secret_basic&quot;,<br>    &quot;client_secret_post&quot;<br>  ],<br>  &quot;claims_supported&quot;: [<br>    &quot;sub&quot;,<br>    &quot;iss&quot;,<br>    &quot;aud&quot;,<br>    &quot;exp&quot;,<br>    &quot;iat&quot;,<br>    &quot;name&quot;,<br>    &quot;email&quot;,<br>    &quot;preferred_username&quot;<br>  ],<br>  &quot;code_challenge_methods_supported&quot;: [&quot;plain&quot;, &quot;S256&quot;]<br>}</pre><p>You’ll notice a field called jwks_uri. That’s the URL where you can find the public keys used by the authorization server.</p><p>If you fetch the jwks_uri, you’ll get something like this:</p><pre>{<br>  &quot;keys&quot;: [<br>    {<br>      &quot;kty&quot;: &quot;RSA&quot;,<br>      &quot;kid&quot;: &quot;abc123&quot;,<br>      &quot;use&quot;: &quot;sig&quot;,<br>      &quot;alg&quot;: &quot;RS256&quot;,<br>      &quot;n&quot;: &quot;sXchv8yGZTuEPl2C_JjSOdKw4VWEZ_r3sZHP...&lt;truncated&gt;&quot;,<br>      &quot;e&quot;: &quot;AQAB&quot;<br>    }<br>  ]<br>}</pre><p>There might be one or multiple keys listed here, depending on the server.<br>Each key will have a kid (Key ID), which is an identifier for that specific key.</p><p>You match the kid in the JWT header with the correct key from this list to verify the token’s signature.</p><p>At this point, you need to validate the token. You shouldn’t be writing custom cryptographic code by hand — instead, always use a well-known library for this (like jsonwebtoken, jose, etc.).</p><p>The idea is simple: you pass the JSON Web Token and the public key to the library, and it will tell you whether the token’s signature is valid or not.</p><p>If the token is valid, the next step is to manually check the important fields inside the payload:</p><p>iss: Make sure the token was issued by your authorization server. This prevents your API from accepting tokens from random or malicious OAuth servers.</p><p>aud: Check if the audience matches your resource server.</p><p>If you have multiple resource servers, you don’t want one server accidentally accepting a token meant for another server.</p><p>exp: Verify that the token hasn’t expired.</p><p>iat: Check the issued-at time if needed (to ensure the token isn’t absurdly old or not yet valid).</p><p>then you should validate the timestamps</p><p>You should always validate these timestamps properly.</p><p>These are the <em>bare minimum</em> checks you should do for every token.<br> Depending on your system, there might be other properties you’ll also want to validate based on your needs.</p><p>When you’re building an OAuth system, it’s super important to think carefully about how long your access tokens should be valid.</p><p>If you set a <strong>long expiration time</strong>, it can cause problems:</p><ul><li>If you need to revoke a token (maybe you banned a user or removed them from the system), the token will still be valid until it naturally expires.</li><li>That means someone could continue accessing your APIs even after they shouldn’t.</li></ul><p>On the other hand, if you make the token <strong>too short-lived</strong>, you’ll run into a different issue:</p><ul><li>Your authorization server will get hammered with requests for new access tokens all the time.</li><li>That can slow down your system and cause heavy load/traffic on the authorization server.</li></ul><p>You have to find a good balance based on your system’s needs.</p><h3>What is a Refresh TOKEN 🔑?</h3><p>A refresh token is used by a client application to get a new access token without making the user log in again.</p><p>It’s part of the OAuth 2.0 Authorization Code Flow and is usually long-lived — meaning it can stay valid for a long time, like 2 hours, 15 days, or even longer or shorter, depending on your system’s security policies.</p><p>When the access token expires (which usually happens pretty fast for security reasons — like in 15 minutes or 1 hour), the client can use the refresh token to start a <em>Refresh Token Flow</em> and get a brand new access token without bothering the user.</p><p>Here’s how the <strong>Refresh Token Flow</strong> works:</p><ol><li>During the initial <strong>Authorization Code Flow</strong>, the client receives both an <strong>access token</strong> and a <strong>refresh token</strong> from the authorization server.</li><li>When the access token expires, the client sends the <strong>refresh token</strong> to the <strong>authorization server</strong>.</li><li>If the refresh token is valid and hasn’t been revoked or expired, the server responds with a <strong>new access token</strong></li></ol><p>This process improves the user experience — users stay logged in without having to re-authenticate, while the system stays secure by rotating short-lived access tokens.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=05f5d8104421" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Part 5: Kafka Internals: Brokers, Clusters, and Offsets Demystified]]></title>
            <link>https://medium.com/@ajwardayyoob/part-5-kafka-internals-brokers-clusters-and-offsets-demystified-4f241102166f?source=rss-d24d94c5f383------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f241102166f</guid>
            <category><![CDATA[kafka-consumer]]></category>
            <category><![CDATA[apache-kafka]]></category>
            <category><![CDATA[event-driven-architecture]]></category>
            <category><![CDATA[kafka]]></category>
            <dc:creator><![CDATA[Ayyoob Ajward]]></dc:creator>
            <pubDate>Wed, 23 Apr 2025 18:42:30 GMT</pubDate>
            <atom:updated>2025-04-23T18:42:30.019Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><em>To truly understand Kafka, it’s important to look under the hood. In this final part, we’ll explore the infrastructure that makes Kafka run — brokers, clusters, and how offsets are used to manage message consumption reliably.</em></blockquote><h3>Brokers and Clusters</h3><p>A single <strong>Kafka server</strong> is called a <strong>broker. </strong>The broker receives messages from producers, assigns offsets to them, and commits the messages to storage on disk.</p><blockquote><strong><em>Note: Retention Period</em></strong></blockquote><blockquote><em>The retention period of a message in a partition can be determined by either:</em></blockquote><blockquote><em>• A specific duration, e.g., 7 days.</em></blockquote><blockquote><em>• A size limit for the topic, e.g., 1024 bytes (1GB).</em></blockquote><blockquote><em>We can also configure different retention policies for different topics. For example:</em></blockquote><blockquote><em>• </em><strong><em>Topic A</em></strong><em>: Retention period is set to 7 days.</em></blockquote><blockquote><em>• </em><strong><em>Topic B</em></strong><em>: Retention period is set to 1TB.</em></blockquote><p>It also services consumers, responding to fetch requests for partitions and responding with the messages that have been committed to disk. Depending on the specific hardware and its performance characteristics, a single broker can easily handle thousands of partitions and millions of messages per second.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8NvXxNecEMU6oRPi.jpeg" /></figure><p>Kafka brokers are designed to operate as part of a cluster. Within a cluster of brokers, one broker will also function as the <strong>cluster controller</strong> (elected automatically from the live members of the cluster).</p><p>The controller is responsible for administrative operations, including</p><ul><li><strong>assigning partitions to brokers</strong></li><li><strong>monitoring for broker failures</strong></li></ul><p>A partition is owned by a single broker in the cluster, and that broker is called the <strong>leader of the partition</strong>. A partition may be <strong>assigned to multiple brokers</strong>, which will result in the <strong>partition being replicated.</strong></p><p>This provides redundancy of messages in the partition, such that another broker can <strong>take over leadership</strong> if there is a <strong>broker failure.</strong></p><blockquote><em>Kafka Zookeeper</em></blockquote><blockquote><em>Apache Kafka uses Zookeeper to store metadata about the Kafka cluster, as well as consumer client details such as server-id.</em></blockquote><h3>Consumer Offset</h3><p>Kafka allows consumers in the consumer groups to Kafka brokers to keep track of messages that has been red by the consumers. The position where a consumer read the message lastly, we call it as offset more specifically current offset. If we use <strong><em>poll()</em></strong><em> method, </em>we can get all the messages which are being red by a consumer group.</p><p>We call the action of updating the current position in the partition a <strong><em>commit</em></strong>.</p><p>How does a consumer commit an offset? It produces a message to Kafka to a special <strong>__consumer_offsets</strong> topic, with the committed offset for each partition. Wherever a partition rebalance triggered (e.g. if a new consumer added or a consumer left the group) then all the consumers will get a new partition assigned to them than the one it processed before.</p><p>In order to know where to pick up the work, the consumer will read the latest committed offset of each partition and continue from there.</p><p>Kafka consumer API provides multiple ways of committing offsets.</p><ol><li><strong>Automatic Commit</strong></li><li><strong>Manual Commit</strong></li></ol><p>The easiest way to commit offsets is to allow the consumer to do it for you. If you configure enable.auto.commit=true, then every five seconds the consumer will commit the largest offset your client received from poll(). The five-second interval is the default and is controlled by setting auto.commit.interval.ms. Just like everything else in the consumer, the automatic commits are driven by the poll loop. Whenever you poll, the consumer checks if it is time to commit, and if it is, it will commit the offsets it returned in the last poll.</p><p>In Manual Commit every time when a consumer consumes a message it has to <strong>ACK (acknowledgment). </strong>Then Kafka will know that this message is consumed by this consumer.</p><p>If Kafka didn’t receive an <strong>ACK </strong>from consumer, it will send the message entire batch with the failed message. If the same message failed multiple times, then a lag would be building. To solve the problem, we need to configure some way to bypass the failed message offset by setting the current offset to (current offset + 1). And we can send that message to <strong>DLQ (Dead Letter Queue) </strong>for letter processing if needed.</p><p>Manual commit is very useful when we concern about each individual message like bank transactions. because we cannot commit some messages and ignore the failed ones. Using manual commit we can avoid two main problems in messaging system which are:</p><ol><li>Avoid message missing</li><li>Avoid message duplication</li></ol><p>There are many use cases with <strong>Apache Kafka </strong>where it can be used in CDC (change data capture) configuration for audit trails or database transaction tracking and etc.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f241102166f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Part 3: Kafka Producers & Consumers: How Data Flows Through the System]]></title>
            <link>https://medium.com/@ajwardayyoob/part-3-kafka-producers-consumers-how-data-flows-through-the-system-fb6790f6fadb?source=rss-d24d94c5f383------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb6790f6fadb</guid>
            <category><![CDATA[apache-kafka]]></category>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[kafka-producer]]></category>
            <category><![CDATA[event-driven-architecture]]></category>
            <category><![CDATA[kafka-consumer]]></category>
            <dc:creator><![CDATA[Ayyoob Ajward]]></dc:creator>
            <pubDate>Wed, 23 Apr 2025 18:41:43 GMT</pubDate>
            <atom:updated>2025-04-23T18:41:43.433Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Kafka’s real power shines through in how it allows producers to write data and consumers to read from it. In this part, we’ll dive into the roles of producers and consumers, and how they interact with Kafka’s internal structure.</blockquote><h3>Producers and Consumers</h3><p>Kafka clients are users of the system. There are 02 basic types: <strong>producers</strong> and <strong>consumers</strong>. There are also advanced client APIs — Kafka Connect API for data integration and Kafka Streams for stream processing.</p><p>Producers create new messages. In general, a message will be produced to a specific topic. By default, the producer does not care what partition a specific message is written to and will balance messages over all partitions of a topic evenly.</p><p>In some cases, the producer will direct messages to specific partitions. This is typically done using the message key and a partitioner that will generate a hash of the key and map it to a specific partition. This assures that all messages produced with a given key will get written to the same partition.</p><p>Consumers read messages. The consumer subscribes to one or more topics and reads the messages in the order in which they were produced. The consumer keeps track of which messages it has already consumed by keeping track of the offset of messages.</p><p>The offset is another bit of metadata — an integer value that continually increases — that Kafka adds to each message as it is produced. Each message in a given partition has a unique offset. By storing the offset of the last consumed message for each partition, either in Zookeeper or in Kafka itself, a consumer can stop and restart without losing its place.</p><h3>Consumer Groups</h3><p>Consumers work as part of a consumer group, which is one or more consumers that work together to consume a topic. <strong>The group assures that each partition is only consumed by one member. </strong>The grouping happens using a group ID, e.g., “group-a.”</p><p>Assume there is a consumer group and a <strong>topic with 3 partitions.</strong></p><ul><li>Scenario 01: Consumer group has <strong>2 members</strong></li><li>Scenario 02: Consumer group has <strong>3 members</strong></li><li>Scenario 02: Consumer group has <strong>more than 03 members</strong> e.g., 4 or 5.</li></ul><p>In the first scenario, one consumer will consume from a single partition. For example, Member 1 consumes from Partition 1, while another consumer will consume from the remaining two partitions in the topic. For instance, Member 2 consumes from Partitions 2 and 3.</p><p>In the second scenario, each member will consume from individual partitions in the topic. For example, Member 1 consumes from Partition 1, Member 2 from Partition 2, and Member 3 from Partition 3.</p><p>In the third scenario, three members will consume individual partitions, similar to the second scenario. However, the 4th and 5th members will remain idle and will not consume from any partitions.</p><blockquote><strong><em>Why we need a consumer group?</em></strong></blockquote><blockquote><em>Assume we have a system that reads data from a source and writes it to a topic. Due to the high volume of data produced by the source, multiple services are used to write the data to the topic. However, on the consumer side, there is only one consumer handling all the data. Eventually, the consumer service may fail due to the overwhelming volume of data it needs to process.</em></blockquote><blockquote><em>Just as multiple producers can write to the same topic, we need to enable multiple consumers to read from the same topic by splitting the data between them. To achieve this, we create a consumer group and add more consumers to the group. For this to work, the topic must have multiple partitions since each member in the consumer group can only consume data from one partition. This allows us to scale the application horizontally by adding more consumers to efficiently process the data.</em></blockquote><p>In Kafka for a single topic there can have multiple consumer groups which are consuming from the topic. from each consumer group multiple members can consume from the same partition. but keep in mind that from a single consumer group only one member can consume from a single topic</p><blockquote><strong><em>Why we need multiple consumer groups?</em></strong></blockquote><blockquote><em>Assume there is another service that is interested in the data produced to the topic. With Kafka, we can create a new consumer group for the new service and allow it to consume data from the topic. Now, there are two services consuming from the same topic, and the 02 services can also scale horizontally if needed.</em></blockquote><p>Next, we’ll dive deeper into how consumers scale by working in groups and how Kafka manages partition rebalancing behind the scenes.<br> 👉 <a href="#">Read Part 4: Kafka Consumer Groups and Rebalancing</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb6790f6fadb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Part 4: Understanding Kafka Consumer Groups and How Partition Rebalancing Works]]></title>
            <link>https://medium.com/@ajwardayyoob/part-4-understanding-kafka-consumer-groups-and-how-partition-rebalancing-works-79465579ad9f?source=rss-d24d94c5f383------2</link>
            <guid isPermaLink="false">https://medium.com/p/79465579ad9f</guid>
            <category><![CDATA[event-driven-architecture]]></category>
            <category><![CDATA[apache-kafka]]></category>
            <category><![CDATA[kafka]]></category>
            <dc:creator><![CDATA[Ayyoob Ajward]]></dc:creator>
            <pubDate>Wed, 23 Apr 2025 18:41:06 GMT</pubDate>
            <atom:updated>2025-04-23T18:41:06.969Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Scaling Kafka consumers isn’t just about adding more readers — it’s about managing coordination and balance. In this post, we’ll explore Kafka consumer groups and how partition rebalancing works to ensure efficient message processing.</blockquote><h3>Partition Rebalancing</h3><p>Moving partition ownership from one consumer to another is called a <strong><em>rebalance. </em></strong>Partition rebalancing happens if one member from the consumer group is unavailable, or another consumer is added to the consumer group. Reassignment of partitions to consumers also happen when the topics the consumer group is consuming are modified (e.g., if an administrator adds new partitions).</p><p>Rebalances are important because they provide the consumer group with high availability and scalability (allowing us to easily and safely add and remove consumers), but in the normal course of events they are fairly undesirable. During a rebalance, consumers can’t consume messages, so a rebalance is basically a short window of unavailability of the entire consumer group.</p><p>In addition, when partitions are moved from one consumer to another, the consumer loses its current state, if it was caching any data, it will need to refresh its caches slowing down the application until the consumer sets up its state again.</p><p>The way consumers maintain their membership for the consumer group and the ownership for the partition is by sending heartbeats to a Kafka broker designated as group coordinator every time consumer poll (retrieve records) or commit messages to the consumer_offeset. As long as the consumer is sending heartbeats at regular intervals, it is assumed to be alive, well, and processing messages from its partitions.</p><p>If the consumer stops sending heartbeats for long enough, its session will time out and the group coordinator will consider it dead and trigger a rebalance. If a consumer crashed and stopped processing messages, it will take the group coordinator a few seconds without heartbeats to decide it is dead and trigger the rebalance. During those seconds, no messages will be processed from the partitions owned by the dead consumer. When closing a consumer cleanly, the consumer will notify the group coordinator that it is leaving, and the group coordinator will trigger a rebalance immediately, reducing the gap in processing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WyqeI5DN3J2rGE_h.jpeg" /></figure><blockquote><strong><em>Note:</em></strong><em> there is no guarantee for consumers to get the same partition after the rebalancing.</em></blockquote><p>Let’s wrap up this series by exploring Kafka’s internal mechanics — brokers, clusters, and how Kafka keeps track of message consumption through offsets.<br> 👉 <a href="#">Read Part 5: Kafka Internals — Brokers, Clusters, and Offsets</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=79465579ad9f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Part 2: Kafka Messaging Deep Dive: From Messages to Partitions]]></title>
            <link>https://medium.com/@ajwardayyoob/part-2-kafka-messaging-deep-dive-from-messages-to-partitions-7e9fdf1ae043?source=rss-d24d94c5f383------2</link>
            <guid isPermaLink="false">https://medium.com/p/7e9fdf1ae043</guid>
            <category><![CDATA[apache-kafka]]></category>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[event-driven-architecture]]></category>
            <category><![CDATA[messaging]]></category>
            <dc:creator><![CDATA[Ayyoob Ajward]]></dc:creator>
            <pubDate>Sat, 19 Apr 2025 21:49:10 GMT</pubDate>
            <atom:updated>2025-04-19T21:49:10.925Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>After understanding what Kafka is and why it exists, it’s time to look at how data flows within it. In this post, we’ll explore how Kafka handles messages and how it organizes them using topics and partitions.</blockquote><h3>Messages and Batches</h3><p>The unit of data within Kafka is called a <strong>message</strong>. If you think Kafka from a database background you can think of this as similar to a <strong>row or a record.</strong></p><p>A message is simply an <strong>array of bytes</strong> as far as Kafka is concerned, so it doesn’t have any <strong>specific format or meaning to Kafka</strong>. Message can have an extra bit (optional) for metadata about the message which is referred to as <strong>Key. </strong>Keys are useful when we want to write the message in a particular partition.</p><p>This is how it happens. First, we set a key to the message let’s say the message contains about a customer order. then we can specify the customer id and the key. Let’s say the key is “<strong><em>customer_2133” </em></strong>then put this key into a hashing function like sha256 and we get the output as</p><pre>0d217d4253d8ed1542362da7fec967d639dc1a11c4f817fa4911cd3e429b818b</pre><p>we then convert this into decimal so that we can caclulate the reminder.</p><p>Let’s say our Topic (I’ll explain in the later part what is a topic) has 4 partitions. we divide the hashed value into 4 and get the reminder as the result. And value we got is the partition number where the message is written to. In this example the result is 3. Therefore, it the message will be written to the 3rd indexed (4th) partition.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EfeKlpu9yvq9OgTl.png" /></figure><p>Messages are written into Kafka in batches into the sample topic and partition. A batch is just a collection of messages. The reason Kafka write messages in batches is to reduce the round trip for each message. Also, batches are compressed.</p><h3>Topics and Partitions</h3><p>Messages in Kafka are categorized into topics. Bast analogy for Kafka Topic is a Folder or a database table. Kafka Topics additionally broken down into a number of partitions. Also, partitions can be considered as single commit log / journal / diary where every action or transaction is written down in the order it happened.</p><p>Messages are written to partitions in append-only manner and are read in order from beginning to end. In a topic there should be at least one partition and can have more than one. Within the partition the order for the messages is guaranteed. However, there is no guarantee for the order between the partitions.</p><p>Partitions are the way Kafka provides redundancy and scalability. Redundancy is achieved through <strong>replication</strong>, where each partition has multiple replicas stored on different brokers, ensuring high availability in case of broker failure.</p><p>Scalability is achieved by having multiple partitions in a topic, allowing multiple consumers within a single consumer group to process partitions in parallel, as each partition can be assigned to only one consumer within the group. If there are multiple consumer groups, they can independently consume data from the same partitions, but this does not increase parallelism within a single group.</p><p>With a solid grasp of Kafka’s messaging model, the next step is understanding how data is produced and consumed — meet the Producers and Consumers.<br> 👉 <a href="#">Read Part 3: Kafka Producers &amp; Consumers</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7e9fdf1ae043" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Part 1: Demystifying Kafka: A Beginner’s Guide to Apache Kafka and Its Origins]]></title>
            <link>https://medium.com/@ajwardayyoob/part-1-demystifying-kafka-a-beginners-guide-to-apache-kafka-and-its-origins-f28e32e7d7cd?source=rss-d24d94c5f383------2</link>
            <guid isPermaLink="false">https://medium.com/p/f28e32e7d7cd</guid>
            <category><![CDATA[event-driven-architecture]]></category>
            <category><![CDATA[event-driven-systems]]></category>
            <category><![CDATA[apache-kafka]]></category>
            <category><![CDATA[kafka]]></category>
            <dc:creator><![CDATA[Ayyoob Ajward]]></dc:creator>
            <pubDate>Sat, 19 Apr 2025 21:44:44 GMT</pubDate>
            <atom:updated>2025-04-19T22:03:47.558Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><em>Apache Kafka is one of the most powerful tools in modern data architecture, but getting started can be overwhelming. In this series, we’ll break Kafka down from the ground up — starting with its origin story and the fundamental concept behind its design.</em></blockquote><blockquote><em>Apache </em><strong><em>Kafka</em></strong><em> is a </em><strong><em>publish/subscribe</em></strong><em> messaging system designed by </em><strong><em>LinkedIn </em></strong><em>to provide a </em><strong><em>high-performance messaging system</em></strong><em> that can handle </em><strong><em>many types of data</em></strong><em> and </em><strong><em>provide clean</em></strong><em>, </em><strong><em>structured data</em></strong></blockquote><h3>Brief History</h3><p>Apache <strong>Kafka</strong> is a <strong>publish/subscribe</strong> messaging system designed by <strong>LinkedIn</strong> and published to open source in 2010. It was designed to provide a high-performance messaging system that can handle many types of data and provide clean, structured data about user <strong>activity and system metrics in real time.</strong></p><h3>What is Apache Kafka</h3><p>Apache Kafka is using the same concept of <strong>publisher/subscriber.</strong> It is that the publisher doesn’t talk directly to consumer instead it places the message in a place where consumer can subscribe to it. If consumer is interested in the message it will consume. This is called <strong>publisher / subscriber pattern.</strong></p><p>If we take a real-world scenario — let’s say we have 2 services, one is order service and other is payment processing service. If a customer placed an order service needs to talk to payment processing service.</p><p>However, assume if payment processing service is down (offline) for some reason, then order service cannot process the order and want to wait until the payment process service is up and running.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tghqE-_IJNB_BFJq.png" /></figure><p>Here you can see order service is highly dependent on order processing service. If it is offline, it cannot process the order. Also let’s assume if order service before it talks to payment service it needs to talk to inventory service. If payment process service is down (offline) then all the previous services requests will fail, and it is called cascade failure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lGxCa21bM0nPwpwT.png" /></figure><p>Cascade Failer in distributed service communition</p><p>In a scenario like this we can use a messaging system like <strong>Apache Kafka</strong> and decouple the inter service communication and dependence. We can follow a principle like separation of concerns where services don’t directly talk to other services instead it passes the message to somewhere other consumer services can get.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CP-Jx-vPFfSWdXZt.png" /></figure><p>Apache Kafka is used in many scenarios. It is mainly used to send some data from one place to another place but in a pub/sub manner. Apache Kafka can do lot more other than what we discussed in the example.</p><p>Now that we’ve covered the basics and history of Kafka, let’s move into how Kafka handles data internally — through messages, batches, topics, and partitions.<br> 👉 <a href="#">Read Part 2: Kafka Messaging Deep Dive</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f28e32e7d7cd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AuthN & AuthZ for Dummies Series — Part 3: Back-Channel vs Front-Channel Communication]]></title>
            <link>https://medium.com/@ajwardayyoob/authn-authz-for-dummies-series-part-3-back-channel-vs-front-channel-communication-caf4986206b7?source=rss-d24d94c5f383------2</link>
            <guid isPermaLink="false">https://medium.com/p/caf4986206b7</guid>
            <category><![CDATA[openid-connect]]></category>
            <category><![CDATA[authorization]]></category>
            <category><![CDATA[oauth]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[oauth2]]></category>
            <dc:creator><![CDATA[Ayyoob Ajward]]></dc:creator>
            <pubDate>Sat, 19 Apr 2025 11:40:54 GMT</pubDate>
            <atom:updated>2025-04-19T12:11:10.824Z</atom:updated>
            <content:encoded><![CDATA[<h3>AuthN &amp; AuthZ for Dummies Series — Part 3: Back-Channel vs Front-Channel Communication</h3><blockquote><strong>Note</strong>: This is Part 3 of the <strong>“AuthN &amp; AuthZ for Dummies”</strong> series. If you’re just joining in, be sure to check out the earlier parts — we’ve already covered the basics, different flows, all of which will help you better understand this part.</blockquote><h3>Front-Channel vs Back-Channel Communication</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yFYYVy8K4uDpq3Hv3t9e1w.png" /><figcaption><strong>Front-Channel vs Back-Channel Communication</strong></figcaption></figure><p>When we talk about grant types or auth flows in OAuth2 and OIDC, we have two communication channels — <strong>Front-Channel</strong> and <strong>Back-Channel</strong>.</p><p>Let’s see why we need two channels to complete this flow.</p><p>Let’s say the Netflix app wants to build a movie recommendation system based on your Facebook preferences — like the pages you follow, the posts you’ve liked or commented on, and the groups you’re in.</p><p>To get a Netflix user’s Facebook account preferences, Facebook must provide an API that returns the relevant information. However, to access the API with specific scopes — like only being able to see the pages the user has liked or the groups they’re in — you need to use Facebook’s authorization server to get an access token. But first, you need to register your application with the authorization server.</p><p>When you register the application with the authorization server, you get two things, and you also need to set a callback URL:</p><ul><li><strong>Client ID — </strong>It is a unique identifier for your Netflix application, like a username.</li><li><strong>Client Secret — </strong>It is like a password that you use in the auth flow.</li><li><strong>Callback URL — </strong>It is used to redirect the user back to the client application and send the authorization code.</li></ul><p>Always remember: <strong>Client ID</strong> — you can use it publicly, while <strong>Client Secret</strong> — you should not expose it publicly. Instead, keep it safely in a private place.</p><p>Because of this, we need two channels: the <strong>Front-Channel</strong>, where only the client ID is shared, and the <strong>Back-Channel</strong>, where you can share the Client Secret. You should <strong>never</strong> share your client secret in the front-channel.</p><blockquote><strong>Note:</strong> This flow always requires human involvement, unlike other OAuth2 flows (like the Client Credentials Flow), which are fully automated.</blockquote><h3>Front-Channel</h3><p>If you’ve read my previous blog post on how the Authorization Code Flow works, you may have noticed — <strong><em>okay, I know you might have forgotten if you read it a while ago, but I’ll recap it here!</em></strong></p><p>There are 3 steps involved in this flow (Authorization Code Flow).</p><p><strong>step 01. — Redirect the user </strong>(Resource Owner ) to<strong> Autherization Service e.g: </strong>Google Login Page</p><p>The client shares this information with the authorization server <strong>via the browser URL itself — not through a background API call</strong>. Because of this, the user is always shown a <strong>consent screen</strong>, rather than the process continuing automatically. This ensures that <strong>the user intentionally agrees to share specific information</strong> with the third-party application, rather than the request being made silently or by someone else on their behalf.</p><p>The <strong>consent screen is crucial</strong> because it not only lets the user approve or deny access, but also allows the authorization server to <strong>verify the user’s identity</strong>, often requiring them to <strong>log in using their username and password</strong>. This step may also include <strong>multi-factor authentication (MFA)</strong>, adding an extra layer of security to confirm that the person granting access is truly the account owner.</p><pre>GET https://auth-server.com/authorize?<br>  response_type=code<br>  &amp;scope=openid email profile<br>  &amp;client_id=YOUR_CLIENT_ID<br>  &amp;redirect_uri=https://ayyoob.com/callback<br>  &amp;state=1234xyz</pre><p>Once the user successfully approves access, the <strong>authorization server redirects the user’s browser to the client’s callback URL</strong>, attaching an <strong>authorization code</strong> as a query parameter.</p><pre>https://ayyoob.com/callback?<br>  code=AUTHORIZATION_CODE<br>  &amp;state=RANDOM_STRING</pre><h3>Back-Channel</h3><p><strong>Step 02.</strong> — The client’s backend then extracts this code and uses it in the <strong>next step of the flow</strong>, which happens over a secure <strong>server-to-server (back-channel) communication using SSL/TLS</strong>.</p><p>This ensures the authorization code is exchanged for an access token in a <strong>confidential and secure</strong> manner, preventing unauthorized parties from intercepting the message.</p><p>In this step, you send a POST request to the authorization server with all the relevant fields, including the client secret.</p><pre>POST https://auth-server.com/token<br><br>grant_type=authorization_code<br>&amp;code=AUTHORIZATION_CODE<br>&amp;redirect_uri=https://yourapp.com/callback<br>&amp;client_id=YOUR_CLIENT_ID<br>&amp;client_secret=YOUR_CLIENT_SECRET</pre><p><strong>Step 03. —</strong> Then the <strong>authorization server validates</strong> the request and responds with:</p><ol><li><strong>Client ID </strong>— which inclues all the user information. (if it is OpenID)</li><li><strong>Access Token / Refresh Token</strong> — what the 3rd party app can access from the user’s account. (if it is Oauth2)</li></ol><h3>Public Clients vs Confidential Clients</h3><p>Before we move on, it’s important to understand <strong>what kind of client is using this flow</strong>, because that influences <strong>how securely the authorization code and access tokens are handled</strong>. In OAuth2, we classify clients into two main types:</p><h4><strong>Public Clients</strong></h4><p>These are clients that <strong>cannot keep a secret</strong>. Think of:</p><ul><li>Single-page applications (SPA) running in the browser — e.g: React/Angular</li><li>Mobile apps</li><li>Any app where the source code can be easily accessed</li></ul><p>Because the code is exposed to the user (or attacker), <strong>you should never store or use the client secret</strong> in these types of clients. These clients rely on <strong>front-channel</strong> communication and often use Authorization Code Flow where we don’t share the client_secret we only share the client_id.</p><h4><strong>Confidential Clients</strong></h4><p>These are clients that <strong>can securely store the client secret</strong>, such as:</p><ul><li>Backend servers</li><li>Server-side web applications</li><li>Trusted internal systems</li></ul><p>Confidential clients <strong>can safely use the back-channel</strong> to send the client secret and get an access token. These are usually registered with a <strong>client secret</strong> and handle the <strong>authorization code exchange securely on the server side</strong>.</p><p><em>What exactly is a </em><strong><em>Refresh Token</em></strong><em>, and </em><strong><em>where should you store</em></strong><em> it?<br></em> Don’t worry — we’ll dive into that in the next parts of this series.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=caf4986206b7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AuthN & AuthZ for Dummies Series — Part 2: OAuth2 and OIDC Flows Explained]]></title>
            <link>https://medium.com/@ajwardayyoob/authn-authz-for-dummies-series-part-2-oauth2-and-oidc-flows-explained-621b182a1aa6?source=rss-d24d94c5f383------2</link>
            <guid isPermaLink="false">https://medium.com/p/621b182a1aa6</guid>
            <category><![CDATA[authorization]]></category>
            <category><![CDATA[openid-connect]]></category>
            <category><![CDATA[oauth2]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[oauth]]></category>
            <dc:creator><![CDATA[Ayyoob Ajward]]></dc:creator>
            <pubDate>Fri, 18 Apr 2025 19:46:14 GMT</pubDate>
            <atom:updated>2025-04-19T11:33:11.320Z</atom:updated>
            <content:encoded><![CDATA[<h3>AuthN &amp; AuthZ for Dummies Series — Part 2: OAuth2 and OIDC Flows Explained</h3><blockquote><strong>Note</strong>: If you missed <strong>Part 1</strong> of this series — <strong><em>“AuthN &amp; AuthZ for Dummies”</em> </strong>— go give it a read first. It covers the basics and sets the stage, so everything in this post will click way easier. Trust me, it’s worth it.OAuth2 and OIDC Grand Types — aka — Flows</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TQp1gT_zScj9utLDc9HO7Q.png" /><figcaption>Oauth and OIDC</figcaption></figure><p>So far, we have discussed what Oauth2 and OIDC really are and what each doing when it comes to Authenticating (who you are?) and Authorizing (what you can do?) and have seen some examples when to use which, more importantly we mention why <strong>Oauth2 introduced which is to prevent 03rd party applications from accessing your username and password of your accounts.</strong></p><blockquote><strong>Note</strong>: If you missed part one of this series, make sure you cover up that so things get much easy for you understand.</blockquote><p>Before getting to the main topic what OIDC and Oauth2 Grant types –AKA — Auth Flows are and Which one to use in which scenario, better you have and understanding of the main components or parties involved in these different types of flows we call it <strong>Roles</strong>.</p><p><strong>Roles of a Auth Flow</strong></p><p><strong>1.</strong> <strong>The User (You): “Resource Owner”</strong></p><p>The resource owner is the person who is giving access to some portion of their account.</p><p><strong>2.</strong> <strong>The Third-Party Application (e.g: 8-ball pool app): “Client”</strong></p><p>The client is the application that is attempting to get access to the user’s account. It needs to get permission from the user before it can do so.</p><p><strong>3.</strong> <strong>The API (e.g: Facebook API server): “Resource Server”</strong></p><p>The resource server is the API server used to access the user’s information.</p><p><strong>4.</strong> <strong>The Authorization Server (e.g: Facebook Auth Server)</strong></p><p>This is the server that presents the interface where the user approves or denies the request. In smaller implementations, this may be the same server as the API server, but larger scale deployments will often build this as a separate component.</p><p>To understand how each in the flow relate to each other, imagine a scenario like this:</p><p><strong>PickMe/Uber</strong> (the client application) wants to <strong>authenticate the user</strong> (resource owner) and <strong>get permission</strong> to access the user’s <strong>Google profile and location data</strong> (resource server) via <strong>Google’s login system</strong> (authorization server).</p><p>The user logs in using their Google account. If they allow it, Google gives PickMe/Uber permission (in the form of a token), so it can access Google Maps APIs (like sharing their current location) on the user’s behalf.</p><p>Now let’s have look at different types of Grant types / Auth Flows used in nowadays in different types of applications like mobile applications, web applications / single page applications (SPA), backend services / IOT devices on so on.</p><p>1. Implicit Flow</p><p>2. Resource Owner Password Flow / Password Grant Type — not recommended to use at all.</p><p>3. Authorization Code Flow — commonly used</p><p>4. Client Credential Flow — commonly used</p><p>5. Device Flow</p><p>6. Refresh Token Flow</p><p>7. PKCE — recommended to use in all types of applications — custom implementation</p><h3><strong>Authorization Code Flow</strong></h3><p>Authorization code flow is the simplest and most widely used code flow. As the name suggests, it’s a flow to share an <strong>authorization code </strong>like a random string value that’s attached in the <strong>redirect URL query param</strong>, and the server then exchanges that code with Google (or whatever authorization server) to get the:</p><ul><li><strong>Identity Token –AKA — ID Token </strong>where all the user information contains when <strong>Authenticating</strong> of the user and or</li><li><strong>Access Token </strong>in the case of Authorization</li></ul><p>Hold on, I know you didn’t get anything. <strong>Believe me</strong>, you’ll understand everything as you read — just give it a bit of time.</p><blockquote><strong><em>Note</em></strong><em>: </em>If you understand this flow, you can understand the rest very easily because all flows are same with slight differences.</blockquote><h4>There are mainly 04 parties involved here as mentioned above in roles:</h4><p>1. Resource Owner (user).</p><p>2. Client (your 3rd party application) — in our case PickMe /Uber.</p><p>3. Resource Server — in our case Google Maps Service.</p><p>4. Authorization Server — in our case it’s also Google Authorization Service.</p><h4><strong>Steps involved in Authorization Code Flow with OIDC / OAuth2:</strong></h4><ol><li><strong>You (the Resource Owner)</strong> click the login button on the <strong>PickMe App (Client)</strong> to log in using Google.</li><li><strong>PickMe App (Client)</strong> redirects you to the <strong>Google Authorization Server</strong> to begin the flow.</li><li>You see the <strong>Google Login UI</strong> — this is the <strong>Authorization Server’s</strong> UI where you enter your credentials. It’s called Concent Screen.</li><li>You log in to <strong>Google (Authorization Server)</strong> with your username and password.</li><li>After successful login, <strong>Google (Authorization Server)</strong> redirects you back to <strong>PickMe App (Client)</strong> with an <strong>Authorization Code</strong> in the URL query param.</li><li><strong>PickMe App (Client)</strong> now sends that <strong>Authorization Code</strong> directly (via backend/server-side) to <strong>Google Authorization Server</strong> to exchange it for tokens.</li><li><strong>Google Authorization Server</strong> validates the code and responds with:</li></ol><ul><li>An <strong>ID Token</strong> (if it’s OIDC — for authentication), and/or</li><li>An <strong>Access Token</strong> (if it’s OAuth2 — for accessing protected APIs like Google Maps).</li></ul><p>8.<strong> PickMe App</strong> can now:</p><ul><li>Use the <strong>ID Token</strong> to understand who you are (authenticate you), or</li><li>Use the <strong>Access Token</strong> to call Google APIs on your behalf (authorize you).</li></ul><p>The steps mentioned above fall under <strong>three main parts</strong>, which is why it’s often called the <strong>Three-Legged OAuth Flow</strong>:</p><ol><li><strong>First leg</strong>: The <strong>client (PickMe App)</strong> sends a request to the <strong>Authorization Server</strong> to initiate the flow. This part happens entirely in the <strong>browser URL</strong> — the client_id, scope, redirect_uri, and other details are sent in the request. After successful login, the <strong>Authorization Server</strong> sends back an <strong>authorization code</strong> in the <strong>redirect URL</strong>.</li><li><strong>Second leg</strong>: The <strong>client</strong> (PickMe App) takes the <strong>authorization code</strong> it just received and makes a <strong>secure POST request</strong> (over SSL/TLS) to the <strong>Authorization Server</strong>. In this request, it sends the client_id, client_secret, redirect_uri, and the authorization_code.</li><li><strong>Third leg</strong>: If everything is valid, the <strong>Authorization Server</strong> responds with a token — either:</li></ol><ul><li>an <strong>ID Token</strong> (for authentication via OIDC), or</li><li>an <strong>Access Token</strong> (for authorization via OAuth2),<br> based on what the client asked for.</li></ul><h4>Here’s how it really happens:</h4><h4>1. Authorization Request :</h4><p>This request is made when initiating the flow with Authorization Server. It includes the following things.</p><pre>GET https://auth-server.com/authorize?<br>  response_type=code<br>  &amp;scope=openid email profile<br>  &amp;client_id=YOUR_CLIENT_ID<br>  &amp;redirect_uri=https://ayyoob.com/callback<br>  &amp;state=1234xyz</pre><ol><li>response_type = code — this means this flow is authorization code flow</li><li>scope = openid email profile — if you’re requesting a Identitiy Token (ID Token) then you need to add openid in the scope. other 02 are optional and you can add more if you want, what those mean is that you will get user (Resourse Owner) email ID and Profile Information in the Identity Token. If you want something else you have to give that in the scope.</li><li>client_id = x13d4289kxzlw193i83 — this identifies your app (Client)(PickMe/Uber). This is used to uniquely identify the client among other clients that are also using the same Authorization Service. This is id is given by the Authorization Service like Google / Facebook / AWS Cognito etc when you register your application (Client) with it initially when you’re developing the app.</li><li>redirect_uri = <a href="https://ayyoob.com/callback">https://ayyoob.com/callback</a> — <em>don’t worry this link doen’t work, anyway</em> this means when you register your application with the Authorization Service you give a redirect url which later used to redirect the user after successfully authenticated / authorized by the authorization service and this is the url which inclues the authorization_code and the state as well e.g: <a href="https://ayyoob.com/callback">https://ayyoob.com/callback</a>?code=81y21j2ye32ins7262</li><li>state = 1234zyx — this is random string generated by your application(client), which it will verify later. You should first compare this state value to ensure it matches the one you started with. You can typically store the state value in a cookie or session, and compare it when the user comes back. This helps ensure your redirection endpoint isn’t able to be tricked into attempting to exchange arbitrary authorization codes. If values are not matching then some one in the middle is messing and intersepting</li></ol><p><strong>The redirect back to the client application :</strong></p><p>This is taking place when you send the initial request with the required parameters and the authorization server will redirect you back to the redirect URL that was provided during the application’s registration by the developer.</p><pre>https://ayyoob.com/callback?<br>  code=AUTHORIZATION_CODE<br>  &amp;state=RANDOM_STRING</pre><blockquote><strong>Hold on!</strong> you didn’t tell me how to register the application yet! ?? — don&#39;t worry will look into that in the next part.</blockquote><h4>2. The request to exchange the authorization code</h4><p>This happens when the client application gets the authorization code in the callback url. once the client extract the authorization code, a POST request will be made from client application — in our case PickMe to the authorization server in the <strong>back-channel</strong> which means no 03rd party can intercept the message since this request is made directly from client to authorization server over SSL/TLS connection.</p><p>In this POST request following things include:</p><pre>POST https://auth-server.com/token<br><br>grant_type=authorization_code<br>&amp;code=AUTHORIZATION_CODE<br>&amp;redirect_uri=https://yourapp.com/callback<br>&amp;client_id=YOUR_CLIENT_ID<br>&amp;client_secret=YOUR_CLIENT_SECRET</pre><ol><li>grant_type = authorizatin_code — this is to indicate that this flow is authorization code flow</li><li>client_id = YOUR_CLIENT_ID — this is to uniquely identify the client application among other client applications registerd in the authorization service</li><li>redirect_uri= <a href="https://yourapp.com/callback">https://yourapp.com/callback</a></li><li>code = AUTHORIZATION_CODE — this is what the client received from authrozation service in the callback url</li><li>client_secret = YOUR_CLIENT_SECRET — since this request is made from server-side code (back-channel), the secret is included</li></ol><h4>If everything checks out, the <strong>Authorization Server</strong> will respond with tokens. What you get depends on what you asked for:</h4><ul><li><strong>Access_Token</strong> — Used to access <strong>protected APIs</strong> (OAuth2).</li><li><strong>ID_Token </strong>— Contains <strong>user identity info</strong> (only if you’re using <strong>OpenID Connect</strong>).</li><li><strong>Refresh_Token</strong> — Optional, used to <strong>refresh access tokens</strong> without requiring the user to log in again (useful for long-lived sessions).</li></ul><pre>{<br>  &quot;access_token&quot;: &quot;ACCESS_TOKEN&quot;,<br>  &quot;id_token&quot;: &quot;ID_TOKEN&quot;,<br>  &quot;refresh_token&quot;: &quot;REFRESH_TOKEN&quot;,<br>  &quot;token_type&quot;: &quot;Bearer&quot;,<br>  &quot;expires_in&quot;: 3600<br>}</pre><blockquote>How really json web token (JWT) works ? it is another topic for another part.</blockquote><p>When you have the id_token, your application can verify <strong>who you are</strong> and let you access features like <strong>booking a cab</strong> or <strong>ordering food</strong> — because it knows you&#39;re logged in.</p><p>When you have an access_token (for example, to the Google Maps API), your app can <strong>fetch your location</strong> or other protected data by sending a request to the Google Maps service <strong>with the token in the request header</strong>.</p><pre>GET /location HTTP/1.1<br>Host: maps.googleapis.com<br>Authorization: Bearer ya29.a0AfH6SMCwXyzExampleAccessToken</pre><h3><strong>Remember this — </strong>If there’s a <strong>User Interface (UI)</strong> involved, the go-to authorization flow is <strong>Authorization Code Flow</strong> — because <strong>user interaction</strong> is a must for this flow.</h3><p>So, how do other flows like Implicit Flow and Client Credentials Flow work? And how do you register the client application (in our case, PickMe App) with the Authorization Server? We’ll dive into Back-Channel vs. Front-Channel communication and discuss where and when to use each one. That’s the next part we’ll be covering!</p><p>Stay tuned! Until then, feel free to recap what we’ve covered so far.</p><p>Good luck! 💪</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=621b182a1aa6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AuthN & AuthZ for Dummies Series — Part 1: Understanding OpenID & OAuth2]]></title>
            <link>https://medium.com/@ajwardayyoob/authn-authz-for-dummies-series-part-1-understanding-openid-oauth2-4a329785f3ef?source=rss-d24d94c5f383------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a329785f3ef</guid>
            <category><![CDATA[oauth]]></category>
            <category><![CDATA[authorization]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[oauth2]]></category>
            <category><![CDATA[openid-connect]]></category>
            <dc:creator><![CDATA[Ayyoob Ajward]]></dc:creator>
            <pubDate>Wed, 16 Apr 2025 20:58:46 GMT</pubDate>
            <atom:updated>2025-04-26T15:50:59.677Z</atom:updated>
            <content:encoded><![CDATA[<h3>AuthN &amp; AuthZ for Dummies Series — Part 1: Understanding <strong>OpenID</strong> &amp; OAuth2</h3><blockquote><strong>Note</strong>: This is just Part 1 of the <strong>“AuthN &amp; AuthZ for Dummies”</strong> series! Up next, we’ll explore Access Tokens, Refresh Tokens, OAuth2 Grant Types, Front-Channel vs. Back-Channel flows, and how it all comes together with real-world examples using AWS Cognito and custome auth server. Stay tuned — things are about to get a lot more hands-on!</blockquote><h3><strong>OpenID Connect (OIDC) and OAuth2</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TQp1gT_zScj9utLDc9HO7Q.png" /><figcaption><strong>OpenID (OIDC) and OAuth2</strong></figcaption></figure><p>Let’s be real for a second — if you’re a software engineer, chances are you’ve come across terms like <strong>OpenID Connect (OIDC)</strong> and <strong>OAuth2</strong>. Maybe you’ve even nodded along in meetings pretending to understand how they work. But deep down, you’re still not quite sure what the difference is, how they actually function, or when to use which one.</p><p>No worries — in this article, we’re going to break it all down <em>in detail</em>. By the end, you’ll not only understand OIDC and OAuth2, but you’ll also know exactly how and when to use them in your own projects.</p><blockquote>BTW it’s okay if you not heard of these tearms at all.</blockquote><p>Imagine you’re building an application — something cool, with lots of features. So you roll up your sleeves, build your APIs, and you’re feeling good. Everything works, you’re proud of it… until you realize there’s a problem.</p><p>This isn’t some open, free-for-all hobby project. This is a real product. Your company — or maybe your investors — are counting on this app to make money. But here’s the catch: anyone, literally <em>anyone</em> in the world, can call your API right now and access those amazing features you built.</p><p>Imagine if that was Netflix — you could just hit an endpoint and watch any TV show or movie without logging in. Or think about Spotify — just stream anything, no subscription needed. That sounds awesome as a user… but as a developer or business? Total nightmare.</p><p>You <em>need</em> a way to make sure only the right people — your actual users or paying customers — can access your API. People who’ve purchased the product. People who’ve subscribed.</p><p>That’s where Authentication (AuthN) and Authorization (AuthZ) come in. And that’s where OIDC and OAuth2 start to matter.</p><p>This is part one of a series where we’ll break down these concepts, explore how they work, and learn how to implement them — step by step. No fluff. No buzzwords. Just real talk for developers like you.</p><p>OIDC and OAuth2 are two protocols that almost every modern authorization server follows — think <strong>Google, Facebook, AWS Cognito, Azure AD </strong>— you name it. They all stick to these standard protocols so that developers (like us) can integrate with them easily by just following the rules of the protocol.</p><p>Here’s the basic breakdown:</p><ul><li><strong>OIDC (OpenID Connect)</strong> is all about <strong>authentication</strong> — it answers the question: <em>“Who are you?”</em></li><li><strong>OAuth2</strong>, on the other hand, is about <strong>authorization</strong> — it answers: <em>“What are you allowed to do?”</em></li></ul><p>Authentication is proving your identity. Authorization is checking your permissions. Two different problems, two protocols working together to solve them.</p><p><strong>OpenID Connect (OIDC)</strong> handles the <strong>authentication</strong> side of things. That means it takes care of stuff like:</p><ul><li>Verifying who the user is</li><li>Password reset flows</li><li>Multi-factor authentication (MFA)</li><li>And a bunch of other security-heavy tasks…</li></ul><p>And let’s be honest — <em>that’s a lot</em>. As a developer, you don’t want to reinvent all of that from scratch.</p><p>So what do you do? You offload that responsibility to an <strong>Identity Provider (IDP)</strong> like Google, Facebook, AWS Cognito, Azure AD, etc. These platforms already follow the OIDC protocol and handle all the messy authentication logic for you.</p><p>That way, <strong>you can stay focused on what actually matters</strong> — building your service and delivering value to your users, not managing logins and MFA headaches.</p><h3>OpenID Connect (OIDC)</h3><p>The main problem <strong>OpenID Connect (OIDC)</strong> solves is this:</p><blockquote><strong><em>How does your system know </em>who<em> the user is?</em></strong></blockquote><p>That’s what OIDC is built for — <strong>it tells your system who the user is</strong>, in a standardized and secure way.</p><p>When you use <strong>OIDC</strong>, you get back a bunch of identity details about the user — things like their <strong>username, email, profile picture</strong>, <strong>and more</strong>. Basically, everything your app needs to know <strong><em>who just logged</em></strong><em> in</em>.</p><p>Now, you might be wondering:<br> <strong>“Why do we even need an ID Token if we already have a username and password?”</strong></p><p>Simple — because with OIDC, the <strong>Identity Provider (IDP)</strong> manages all the user credentials. That means <strong>your application doesn’t need to store, manage, or even see usernames and passwords</strong>.</p><p>This makes your app more secure and much more user-friendly. After all, <strong>nobody wants to enter their credentials every time they log in.</strong></p><p>OIDC solves this by introducing the <strong>ID Token</strong>, which acts like a wristband at a party. The first time you show up, security checks your ID and confirms you’re on the list — then they give you a wristband. After that, you can come and go freely without being stopped every time.</p><p>Same with OIDC — once you’re verified, you get an ID Token. That token proves who you are, so you don’t have to keep logging in again and again.</p><h3>OAuth2</h3><p><strong>OAuth2</strong> is all about <strong>authorization</strong> — it answers the question:</p><blockquote><strong><em>“What is this user allowed to do?”</em></strong></blockquote><p><strong>Let’s simplify OAuth2 with a hotel example. </strong>Imagine you’re checking into a hotel for the night:</p><ol><li>You walk into a hotel and go to the reservation desk — you want a room.</li><li>You book the room — you provide your info and confirm your stay.</li><li>They give you a <strong>key card</strong> — this is your <strong>access token</strong>. It represents the <strong>permissions</strong> you’ve been granted (e.g., access to your room, gym, or pool).</li><li>You use that key card to open your room or enter other authorized areas — the <strong>doors don’t care who you are</strong>, they just check if the <strong>card is valid</strong> and <strong>what it’s allowed to do</strong>.</li><li>As long as you have the card, the hotel trusts you — no need to prove your identity over and over. The <strong>card carries that authority.</strong></li></ol><p><strong>This is how OAuth2 works:</strong></p><ul><li>Instead of giving an app your <strong>username and password</strong> (which is like handing over your house keys), you go through an <strong>authorization process</strong>.</li><li>The app gets an <strong>access token</strong> — like your hotel key card.</li><li>That token is then used to access <strong>specific resources</strong> (like your Facebook friend list or Google Calendar) — but <strong>only what you explicitly allowed</strong>.</li><li>The app doesn’t need to know <em>who you are</em>, just that it has a valid token with the right permissions.</li></ul><p><strong>Let’s make this real with an example.</strong></p><p>Imagine you log into a game like <strong>8-ball Pool</strong> or <strong>PUBG</strong>. Cool — you’re authenticated. The system knows <em>who</em> you are.</p><p>Now let’s say the game wants to show you which of your <strong>Facebook friends</strong> are online, or maybe notify them when you pass a level. To do that, the game needs access to your Facebook account — but not <em>all</em> of it. Just your friend list, maybe your profile picture, and permission to send notifications.</p><p>One <em>very bad</em> way to make that happen would be to give the game your <strong>Facebook username and password</strong>. But that’s a huge security risk. The game would then have full control over your account — it could read private messages, reset your password, even lock you out. This insecure method is known as the <strong>Password Grant Type</strong>, and you should never use it with third-party apps.</p><p><strong>OAuth2</strong> was created to solve this exact problem.</p><p>Rather than handing over your credentials, <strong>you authorize the app</strong> to access specific parts of your data by giving it a <strong>token</strong>. This token acts as temporary proof that the app has your permission to do certain things — like view your friends list — without giving it full access to your account.</p><h3>Use Cases of OAuth2 and OIDC</h3><p>There are 03 use cases for OAuth2 and OIDC</p><ul><li>Using OIDC alone</li><li>Using OAuth2 alone</li><li>Using both OIDC and OAuth2 together</li></ul><ol><li><strong>The app wants to verify <em>who you are</em> (Authentication only — OIDC)</strong></li></ol><p>The goal here is to <strong>log the user in</strong>, using a trusted external identity provider. <strong>Only OIDC is used here.</strong></p><p>Example: The <strong>8-ball Pool</strong> game wants to let users log in using <strong>Google</strong>, <strong>Facebook</strong>, or <strong>enterprise SSO</strong>.</p><ul><li>This is handled by <strong>OpenID Connect (OIDC)</strong>.</li><li>The client (8-ball Pool app) requests an <strong>Identity Token</strong> from the identity provider (like Google).</li><li>The Identity Token contains basic user info like name, email, profile picture — enough to recognize <em>who</em> is using the app.</li></ul><p><strong>2. The app wants to access your data from another service (Authorization only — OAuth2)</strong></p><p>Now the app doesn’t just care who you are — it wants to <strong>access something on your behalf</strong>. <strong>Only OAuth2 is used here.</strong></p><p>Example: After login, the <strong>8-ball Pool</strong> app wants to show your <strong>Facebook friends list</strong> inside the game.</p><ul><li>The app needs permission to call the <strong>Facebook API</strong> using your account.</li><li>Instead of asking for your Facebook credentials, the app gets an <strong>Access Token</strong> from Facebook.</li><li>It then uses this token to fetch your friend list securely.</li></ul><p><strong>3. The app wants to log you in <em>and</em> access your data (Authentication + Authorization — OIDC + OAuth2) — Both OIDC and OAuth2 are used together.</strong></p><p>This is the most common scenario — apps need to do <strong>both</strong>:</p><p>Example: The <strong>8-ball Pool</strong> app wants to:</p><ul><li>Let you <strong>log in using Facebook</strong> (OIDC),</li><li>And also <strong>access your Facebook friends list</strong> (OAuth2).</li></ul><p>The app requests:</p><ul><li>An <strong>Identity Token</strong> to know who you are.</li><li>An <strong>Access Token</strong> to fetch your friends list from the Facebook API</li></ul><p><strong>Simple rule to remember:</strong></p><ul><li>Need to know <em>who</em> the user is? → <strong>OIDC</strong></li><li>Need to access their stuff? → <strong>OAuth2</strong></li><li>Need both? → Use <strong>both protocols together</strong></li></ul><blockquote>This is just Part 1 of the <strong>“AuthN &amp; AuthZ for Dummies”</strong> series! Up next, we’ll explore Access Tokens, Refresh Tokens, OAuth2 Grant Types, Front-Channel vs. Back-Channel flows, and how it all comes together with real-world examples using AWS Cognito. Stay tuned — things are about to get a lot more hands-on!</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a329785f3ef" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>