{"componentChunkName":"component---src-templates-tag-js","path":"/tags/authorization-code-flow/","result":{"data":{"site":{"siteMetadata":{"title":"LoginRadius Blog"}},"allMarkdownRemark":{"totalCount":3,"edges":[{"node":{"fields":{"slug":"/engineering/guide-to-jwt/"},"html":"<h2 id=\"introduction\" style=\"position:relative;\"><a href=\"#introduction\" aria-label=\"introduction permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Introduction</h2>\n<p>Have you ever logged into a website by clicking “Login with Google” or “Sign in with Facebook,” without entering your password? Or used a web app that keeps you logged in even after closing your browser? </p>\n<p>These seamless experiences often rely on JSON Web Tokens (JWTs) — a way to authorize users after they have been authenticated.</p>\n<p>In today’s digital landscape, securing user identity and managing access is critical. JWT is a compact and secure method for transmitting claims between parties, typically used after authentication to handle authorization, session management, and secure API access.</p>\n<p>But what exactly is a JWT, how does it work, and why is it important? This blog offers a comprehensive explanation.</p>\n<h2 id=\"what-are-tokens-and-why-are-they-needed\" style=\"position:relative;\"><a href=\"#what-are-tokens-and-why-are-they-needed\" aria-label=\"what are tokens and why are they needed permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What are Tokens and Why Are They Needed?</h2>\n<p>Tokens are digital artifacts used in authentication systems to represent user identity. Instead of maintaining session state on the server, modern applications issue tokens to clients. These tokens are sent along with each request to authorize access to protected resources.</p>\n<p>When a user makes an authenticated request, the token is included in the request header. The server verifies the token’s validity—typically by checking its signature and expiration time. If the token is valid, access is granted. This approach supports stateless and scalable systems, compared to traditional session-based models.</p>\n<p><img src=\"/dd1314dc0f7dba888ea4df48ac00ccbe/token-authentication-method.webp\" alt=\"Illustration depicting authentication in mobile device and PC through token authentication method.\"></p>\n<h2 id=\"what-is-jwt-json-web-token\" style=\"position:relative;\"><a href=\"#what-is-jwt-json-web-token\" aria-label=\"what is jwt json web token permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What is JWT (JSON Web Token)?</h2>\n<p><a href=\"https://www.loginradius.com/blog/engineering/jwt/\">A JWT (JSON Web Token)</a> is a compact, self-contained token used to securely transmit claims between parties. JWTs are digitally signed using a secret (with HMAC) or a public/private key pair (with RSA or ECDSA).</p>\n<p>One of the main advantages of JWT authentication is that it doesn't require storing session data on the server—making it ideal for distributed applications.</p>\n<h2 id=\"types-of-jwt\" style=\"position:relative;\"><a href=\"#types-of-jwt\" aria-label=\"types of jwt permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Types of JWT</h2>\n<p>There are two main types of JWT based on how the payload is protected- JWS and JWE. Let’s learn more about them. </p>\n<h3 id=\"jws-json-web-signature\" style=\"position:relative;\"><a href=\"#jws-json-web-signature\" aria-label=\"jws json web signature permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>JWS (JSON Web Signature)</h3>\n<p>JWS is a type of JWT where the payload (data) is digitally signed, ensuring integrity and authenticity of the token.</p>\n<ul>\n<li>The payload is Base64URL encoded and signed using a secret or private key. </li>\n<li>It is not encrypted, meaning the contents can be read by anyone who has the token. </li>\n<li>Commonly used in authentication and authorization scenarios like OAuth 2.0 access tokens. </li>\n</ul>\n<p><strong>Use Case:</strong> Verifying that the data has not been tampered with.</p>\n<h3 id=\"jwe-json-web-encryption\" style=\"position:relative;\"><a href=\"#jwe-json-web-encryption\" aria-label=\"jwe json web encryption permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>JWE (JSON Web Encryption)?</h3>\n<p>JWE is a type of JWT where the payload is encrypted, ensuring confidentiality in addition to integrity.</p>\n<ul>\n<li>The entire payload is encrypted using a public key or shared secret. </li>\n<li>Only the intended recipient can decrypt and read the token contents. </li>\n<li>Less common than JWS, but ideal for sensitive data transmission. </li>\n</ul>\n<p><strong>Use Case:</strong> Protecting personal or confidential information during transit.</p>\n<h2 id=\"jwt-vs-jws-vs-jwe--comparison-table\" style=\"position:relative;\"><a href=\"#jwt-vs-jws-vs-jwe--comparison-table\" aria-label=\"jwt vs jws vs jwe  comparison table permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>JWT vs JWS vs JWE – Comparison Table</h2>\n<table>\n  <tr>\n   <td><strong>Feature</strong>\n   </td>\n   <td><strong>JWT (General)</strong>\n   </td>\n   <td><strong>JWS (Signed JWT)</strong>\n   </td>\n   <td><strong>JWE (Encrypted JWT)</strong>\n   </td>\n  </tr>\n  <tr>\n   <td><strong>Security Focus</strong>\n   </td>\n   <td>Token Format\n   </td>\n   <td>Integrity, authenticity\n   </td>\n   <td>Confidentiality + integrity\n   </td>\n  </tr>\n  <tr>\n   <td><strong>Payload</strong>\n   </td>\n   <td>Not specified\n   </td>\n   <td>Base64URL encoded (readable)\n   </td>\n   <td>Encrypted (not readable)\n   </td>\n  </tr>\n  <tr>\n   <td><strong>Signature</strong>\n   </td>\n   <td>Optional\n   </td>\n   <td>Required\n   </td>\n   <td>Encrypted along with payload\n   </td>\n  </tr>\n  <tr>\n   <td><strong>Encryption</strong>\n   </td>\n   <td>Optional\n   </td>\n   <td>Not encrypted\n   </td>\n   <td>Fully encrypted\n   </td>\n  </tr>\n  <tr>\n   <td><strong>Use Case</strong>\n   </td>\n   <td>ID and Access Tokens\n   </td>\n   <td>OAuth 2.0, OpenID Connect\n   </td>\n   <td>Highly sensitive information\n   </td>\n  </tr>\n</table>\n<p>Note: JWT is the umbrella format. JWS and JWE are implementation types. The most commonly used JWTs in web apps are of the JWS type.</p>\n<h2 id=\"structure-of-jwt\" style=\"position:relative;\"><a href=\"#structure-of-jwt\" aria-label=\"structure of jwt permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Structure of JWT</h2>\n<p>A JWT is composed of three parts:</p>\n<ol>\n<li><strong>Header</strong></li>\n<li><strong>Payload</strong></li>\n<li><strong>Signature</strong></li>\n</ol>\n<p>Each part is Base64URL encoded and separated by a period (.).</p>\n<p><strong>Example:</strong></p>\n<p>&#x3C;Header>.&#x3C;Payload>.&#x3C;Signature></p>\n<h3 id=\"1-header\" style=\"position:relative;\"><a href=\"#1-header\" aria-label=\"1 header permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>1. Header</h3>\n<p>The header typically includes the token type and the signing algorithm being used.</p>\n<p>{</p>\n<p>  \"alg\": \"HS256\",</p>\n<p>  \"typ\": \"JWT\"</p>\n<p>}</p>\n<h3 id=\"2-payload\" style=\"position:relative;\"><a href=\"#2-payload\" aria-label=\"2 payload permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>2. Payload</h3>\n<p>The payload contains the <strong>claims</strong>—statements about an entity (usually the user) and additional metadata.</p>\n<p>{</p>\n<p>  \"iss\": \"<a href=\"https://lrSiteName.hub.loginradius.com/%22\">https://lrSiteName.hub.loginradius.com/\"</a>,</p>\n<p>  \"sub\": \"{uid}\",</p>\n<p>  \"jti\": \"unique string\",</p>\n<p>  \"iat\": 1573849217,</p>\n<p>  \"nbf\": 1573849217,</p>\n<p>  \"exp\": 1573849817,</p>\n<p>  \"Key1\": \"value1\",</p>\n<p>  \"Key2\": \"value2\"</p>\n<p>}</p>\n<h4 id=\"standard-jwt-claims\" style=\"position:relative;\"><a href=\"#standard-jwt-claims\" aria-label=\"standard jwt claims permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><strong>Standard JWT Claims</strong></h4>\n<ul>\n<li><strong>iss (Issuer):</strong> Identifies the token issuer (e.g., your LoginRadius domain). </li>\n<li><strong>sub (Subject):</strong> Identifies the user or entity to whom the token refers. </li>\n<li><strong>jti (JWT ID):</strong> Unique identifier for the token, often used to prevent replay attacks. </li>\n<li><strong>iat (Issued At):</strong> Timestamp of when the token was issued. </li>\n<li><strong>nbf (Not Before):</strong> Specifies the time before which the token must not be accepted. </li>\n<li><strong>exp (Expiration):</strong> Sets token expiration—once expired, access is denied. </li>\n</ul>\n<p>Note: The payload is not encrypted by default, and can be decoded by anyone. Do not include sensitive information unless using an encrypted JWT (JWE).</p>\n<h3 id=\"3-signature\" style=\"position:relative;\"><a href=\"#3-signature\" aria-label=\"3 signature permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>3. Signature</h3>\n<p>The signature ensures the token has not been altered. It is created by signing the encoded header and payload using a secret or private key.</p>\n<p>HMACSHA256(</p>\n<p>  base64UrlEncode(header) + \".\" +</p>\n<p>  base64UrlEncode(payload),</p>\n<p>  secret)</p>\n<p>This helps validate the token’s integrity and authenticity.</p>\n<h2 id=\"how-does-jwt-work\" style=\"position:relative;\"><a href=\"#how-does-jwt-work\" aria-label=\"how does jwt work permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>How Does JWT Work?</h2>\n<p>JWT-based authentication typically follows this flow:</p>\n<ol>\n<li><strong>User Logs In</strong></li>\n</ol>\n<p>The user provides login credentials (e.g., username and password). </p>\n<ol start=\"2\">\n<li><strong>Server Verifies Credentials</strong> </li>\n</ol>\n<p>The server validates the credentials against its data store. </p>\n<ol start=\"3\">\n<li><strong>JWT is Issued</strong> </li>\n</ol>\n<p>Upon successful login, the server issues a JWT signed with a secret/private key (post authentication). </p>\n<ol start=\"4\">\n<li><strong>Client Stores JWT</strong> </li>\n</ol>\n<p>The client stores the token (e.g., in localStorage, sessionStorage, or a secure cookie). </p>\n<ol start=\"5\">\n<li><strong>Token Sent on Requests</strong> </li>\n</ol>\n<p>The client attaches the token to the Authorization header (Bearer &#x3C;token>) in future authorization/authentication API requests.</p>\n<ol start=\"6\">\n<li><strong>Server Validates JWT</strong> </li>\n</ol>\n<p>The server checks the token's signature, expiry, and validity. </p>\n<ol start=\"7\">\n<li><strong>Access is Granted</strong> </li>\n</ol>\n<p>If valid, the user is granted access to protected resources.</p>\n<p>This stateless model makes JWT ideal for scalable web and mobile apps.</p>\n<h2 id=\"how-to-use-oauth-20-with-jwt\" style=\"position:relative;\"><a href=\"#how-to-use-oauth-20-with-jwt\" aria-label=\"how to use oauth 20 with jwt permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>How to Use OAuth 2.0 with JWT</h2>\n<p><a href=\"https://www.loginradius.com/blog/engineering/what-is-oauth2-0/\">OAuth 2.0</a> is an industry-standard protocol for authorization. It enables users to grant third-party apps access to their resources without sharing their credentials.</p>\n<p>When integrated with JWT, OAuth 2.0 uses JWTs as access tokens to represent the user's authorization.</p>\n<p>JWTs are commonly used as OAuth 2.0 access tokens—but not required by the specification. Some providers use opaque tokens instead.</p>\n<p><a href=\"https://www.loginradius.com/resource/whitepaper/secure-api-using-oauth2\"><img src=\"/dce2d7af3a212b2cf75c6b810d4444e2/api-economy.webp\" alt=\"Illustration showing loginradius’s free downloadable resource named- API Economy is transforming digitization- how to secure it using oauth 2.0.\"></a></p>\n<h3 id=\"why-jwts-in-oauth-20\" style=\"position:relative;\"><a href=\"#why-jwts-in-oauth-20\" aria-label=\"why jwts in oauth 20 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Why JWTs in OAuth 2.0?</h3>\n<ul>\n<li>JWTs are <strong>self-contained</strong>, carrying all claims. </li>\n<li>They are <strong>digitally signed</strong>, allowing recipients to verify them without contacting the issuer. </li>\n<li>They improve performance by <strong>eliminating database lookups</strong> during request processing. </li>\n</ul>\n<h2 id=\"implementation-of-jwt-using-loginradius-apis\" style=\"position:relative;\"><a href=\"#implementation-of-jwt-using-loginradius-apis\" aria-label=\"implementation of jwt using loginradius apis permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Implementation of JWT using LoginRadius APIs</h2>\n<p>To implement JWT with LoginRadius:</p>\n<h3 id=\"step-1-configure-a-jwt-app\" style=\"position:relative;\"><a href=\"#step-1-configure-a-jwt-app\" aria-label=\"step 1 configure a jwt app permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><strong>Step 1: Configure a JWT App</strong></h3>\n<p>Set up a JWT app in your <a href=\"https://accounts.loginradius.com/auth.aspx?return_url=https://console.loginradius.com/login&#x26;action=register\">LoginRadius Admin Console</a>. Follow the JWT Admin Console Configuration guide.</p>\n<p><img src=\"/a3ccb47d5a3d66fc01c0eeac6c26328b/jwt-configuration.webp\" alt=\"Illustration showing loginradius admin console with jwt configuration where users can manage access token and refresh token settings.\"></p>\n<h3 id=\"step-2-use-apis-to-retrieve-jwt\" style=\"position:relative;\"><a href=\"#step-2-use-apis-to-retrieve-jwt\" aria-label=\"step 2 use apis to retrieve jwt permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><strong>Step 2: Use APIs to Retrieve JWT</strong></h3>\n<p>If you are directly implementing your Login forms or already have an access token or want to generate a JWT based on email/username/Phone number or a password, you can leverage the following APIs:</p>\n<ul>\n<li><a href=\"https://www.loginradius.com/docs/api/v2/single-sign-on/federated-sso/jwt-login/jwt-token-by-access-token/\">JWT Token</a>: This GET API is used to exchange access tokens with your JWT.</li>\n<li><a href=\"https://www.loginradius.com/docs/api/v2/single-sign-on/federated-sso/jwt-login/jwt-token-by-email-and-password/\">JWT Token by Email</a>: This API is used to get a JWT by Email and Password.</li>\n<li><a href=\"https://www.loginradius.com/docs/api/v2/single-sign-on/federated-sso/jwt-login/jwt-token-by-username-and-password/\">JWT Token by Username</a>: This API is used to get JWT by Username and password.</li>\n<li><a href=\"https://www.loginradius.com/docs/api/v2/single-sign-on/federated-sso/jwt-login/jwt-token-by-phone-and-password/\">JWT Token by Phone</a>: This API is used to get JWT by Phone and password.</li>\n</ul>\n<p><strong>API Response Example:</strong></p>\n<p>{</p>\n<p>  \"signature\": \"&#x3C;JWTresponse>\"</p>\n<p>}</p>\n<p>These tokens can then be used in your client app for authenticated requests.</p>\n<h2 id=\"best-practices-for-secure-jwt-authentication\" style=\"position:relative;\"><a href=\"#best-practices-for-secure-jwt-authentication\" aria-label=\"best practices for secure jwt authentication permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Best Practices for Secure JWT Authentication</h2>\n<p>To implement JWT securely, follow these key practices:</p>\n<ol>\n<li><strong>Keep Signing Keys Secure</strong> </li>\n</ol>\n<p>Private keys or secrets used to sign JWTs must be stored securely. </p>\n<ol start=\"2\">\n<li><strong>Avoid Sensitive Data in Payload</strong> </li>\n</ol>\n<p>Payload is only base64 encoded—not encrypted. Do not include passwords, PII, or credentials unless using encrypted JWT (JWE).</p>\n<ol start=\"3\">\n<li><strong>Limit Token Claims</strong> </li>\n</ol>\n<p>Include only essential claims in the token to reduce size and exposure.</p>\n<ol start=\"4\">\n<li><strong>Use HTTPS</strong> </li>\n</ol>\n<p>Always transmit JWTs over HTTPS to prevent man-in-the-middle attacks.</p>\n<ol start=\"5\">\n<li><strong>Set Short Expiry Times</strong> </li>\n</ol>\n<p>Use short exp durations and implement refresh tokens to reduce impact if a token is compromised.</p>\n<ol start=\"6\">\n<li><strong>Implement Token Revocation</strong> </li>\n</ol>\n<p>Use jti with a blacklist or maintain a revocation strategy for enhanced control.</p>\n<h2 id=\"why-are-jwts-important-for-authentication-and-security\" style=\"position:relative;\"><a href=\"#why-are-jwts-important-for-authentication-and-security\" aria-label=\"why are jwts important for authentication and security permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Why Are JWTs Important for Authentication and Security?</h2>\n<p>JWTs offer numerous benefits in authentication systems:</p>\n<ul>\n<li><strong>Stateless Authentication</strong> – No need to maintain session state on the server. </li>\n<li><strong>Scalability</strong> – Suitable for microservices and distributed systems. </li>\n<li><strong>Tamper Resistance</strong> – Digitally signed tokens ensure data integrity. </li>\n<li><strong>Performance</strong> – Reduces server load and database dependencies. </li>\n<li><strong>Cross-Platform Support</strong> – Easily used across web, mobile, and API ecosystems.</li>\n<li><strong>Enhanced Security</strong> – Signed tokens ensure authenticity and tamper-proof data. </li>\n<li><strong>Developer Convenience</strong> – Simplifies session management. </li>\n</ul>\n<p>JWTs are widely adopted in OAuth 2.0, OpenID Connect, and API security implementations.</p>\n<h2 id=\"conclusion\" style=\"position:relative;\"><a href=\"#conclusion\" aria-label=\"conclusion permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Conclusion</h2>\n<p>JWT authentication is a robust, efficient, and secure method for protecting web and mobile applications. By understanding its structure, use cases, and best practices, you can confidently implement JWTs in modern authentication systems.</p>\n<p>Looking to implement JWT in your application? Check out the <a href=\"https://www.loginradius.com/docs/single-sign-on/federated-sso/jwt-login/overview/?q=jwt+\">developer documentation</a> to get started with seamless JWT integration using LoginRadius.</p>\n<h2 id=\"faqs\" style=\"position:relative;\"><a href=\"#faqs\" aria-label=\"faqs permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><strong>FAQ’s</strong></h2>\n<h3 id=\"1-what-is-the-expiration-time-of-jwt-and-what-is-the-measurement-of-time-in-jwt\" style=\"position:relative;\"><a href=\"#1-what-is-the-expiration-time-of-jwt-and-what-is-the-measurement-of-time-in-jwt\" aria-label=\"1 what is the expiration time of jwt and what is the measurement of time in jwt permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><strong>1.</strong> What is the expiration time of JWT, and what is the measurement of time in JWT?</h3>\n<p><strong>A:</strong> By default, the expiry time of a JWT is 600 seconds (10 Minutes). It is shown in the form of seconds in the JWT configuration. The expiry time can be set from 1 second to 2592000 seconds (30 days) as per your use case.</p>\n<h3 id=\"2-what-is-the-difference-between-oauth-and-jwt\" style=\"position:relative;\"><a href=\"#2-what-is-the-difference-between-oauth-and-jwt\" aria-label=\"2 what is the difference between oauth and jwt permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><strong>2.</strong> What is the difference between OAuth and JWT?</h3>\n<p><strong>A:</strong> OAuth is an authorization framework, that allows third-party apps to access user data without exposing their credentials.JWT is used at the end of authentication to securely transmit user info (identity and authorization). Use OAuth for delegated access; use JWT for stateless authentication and API authorization (verifying within your own system).</p>\n<h3 id=\"3-how-many-types-of-jwt-are-there\" style=\"position:relative;\"><a href=\"#3-how-many-types-of-jwt-are-there\" aria-label=\"3 how many types of jwt are there permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><strong>3.</strong> How many types of JWT are there?</h3>\n<p><strong>A:</strong> JWTs mainly come in two types, with one being JSON Web Signature (JWS) and JSON Web Encryption (JWE). In JWS, the token’s content is digitally signed to protect it from tampering during transmission between sender and receiver. While the data is secure from modification, its contents (claims) can still be visible to others. </p>\n<style class=\"grvsc-styles\">\n  .grvsc-container {\n    overflow: auto;\n    -webkit-overflow-scrolling: touch;\n    padding-top: 1rem;\n    padding-top: var(--grvsc-padding-top, var(--grvsc-padding-v, 1rem));\n    padding-bottom: 1rem;\n    padding-bottom: var(--grvsc-padding-bottom, var(--grvsc-padding-v, 1rem));\n    border-radius: 8px;\n    border-radius: var(--grvsc-border-radius, 8px);\n    font-feature-settings: normal;\n  }\n  \n  .grvsc-code {\n    display: inline-block;\n    min-width: 100%;\n  }\n  \n  .grvsc-line {\n    display: inline-block;\n    box-sizing: border-box;\n    width: 100%;\n    padding-left: 1.5rem;\n    padding-left: var(--grvsc-padding-left, var(--grvsc-padding-h, 1.5rem));\n    padding-right: 1.5rem;\n    padding-right: var(--grvsc-padding-right, var(--grvsc-padding-h, 1.5rem));\n  }\n  \n  .grvsc-line-highlighted {\n    background-color: var(--grvsc-line-highlighted-background-color, transparent);\n    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, transparent);\n  }\n  \n</style>","frontmatter":{"date":"April 07, 2025","updated_date":null,"title":"Complete Guide to JSON Web Token (JWT) and How It Works","tags":["Oauth","Authorization Code Flow","Authorization","Authentication"],"coverImage":{"childImageSharp":{"fluid":{"aspectRatio":1.6528925619834711,"src":"/static/91ea5ae9cba0662d9830e037814a0409/58556/guide-to-jwt.webp","srcSet":"/static/91ea5ae9cba0662d9830e037814a0409/61e93/guide-to-jwt.webp 200w,\n/static/91ea5ae9cba0662d9830e037814a0409/1f5c5/guide-to-jwt.webp 400w,\n/static/91ea5ae9cba0662d9830e037814a0409/58556/guide-to-jwt.webp 800w,\n/static/91ea5ae9cba0662d9830e037814a0409/99238/guide-to-jwt.webp 1200w,\n/static/91ea5ae9cba0662d9830e037814a0409/7c22d/guide-to-jwt.webp 1600w,\n/static/91ea5ae9cba0662d9830e037814a0409/a5bb9/guide-to-jwt.webp 5115w","sizes":"(max-width: 800px) 100vw, 800px"}}},"author":{"id":"Kundan Singh","github":null,"avatar":null}}}},{"node":{"fields":{"slug":"/engineering/what-is-oauth2-0/"},"html":"<h2 id=\"introduction\" style=\"position:relative;\"><a href=\"#introduction\" aria-label=\"introduction permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Introduction</h2>\n<p>Have you ever used \"Login with Google\" or granted an app permission to access your private files from the cloud? That’s OAuth 2.0 in action. </p>\n<p>OAuth 2.0 is a secure authorization framework that allows applications to access your data without having to share passwords. While often mistaken as an Authentication framework, OAuth 2.0 strictly deals with authorization, using access tokens to grant permissions to resources for a specified period.</p>\n<p>However, if you’re also unclear about how authentication differs from authorization? Check out our detailed blog:<a href=\"https://www.loginradius.com/blog/identity/authentication-vs-authorization-infographic/\"> Authentication vs. Authorization</a>.</p>\n<p>OAuth 2.0 is an important part of modern authorization. It helps platforms keep access controls secure and organized. It also makes it easy to manage user interactions. </p>\n<p>In this blog, we will break down how OAuth 2.0 works, why it is important and how it improves upon its predecessor,  OAuth 1.0.</p>\n<h2 id=\"what-is-oauth-20\" style=\"position:relative;\"><a href=\"#what-is-oauth-20\" aria-label=\"what is oauth 20 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What is OAuth 2.0?</h2>\n<p>OAuth 2.0 is a <a href=\"https://www.loginradius.com/blog/engineering/authorization-code-flow-oauth/\">token-based authorization</a> framework that provides access to resources without sharing user credentials. Suppose you have some pictures in a cloud drive that you wish to print from a local photo printing shop. You can enable the print shop to access your photos in this drive without sharing your password by using OAuth 2.0 authentication. </p>\n<p>This keeps your account safe. It lets the shop access the information it needs. It also makes sure they cannot see anything else in your personal account. In essence, OAuth 2.0 serves the purpose of managing privacy and safety of your information as well as granting the permissions needed.</p>\n<h2 id=\"need-for-oauth-20\" style=\"position:relative;\"><a href=\"#need-for-oauth-20\" aria-label=\"need for oauth 20 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Need for OAuth 2.0</h2>\n<p>Before OAuth, users had to share actual credentials (username and password) with applications that needed to access their data. We all understand why this approach was risky. </p>\n<h3 id=\"oauth-10-the-first-step-toward-secure-authorization\" style=\"position:relative;\"><a href=\"#oauth-10-the-first-step-toward-secure-authorization\" aria-label=\"oauth 10 the first step toward secure authorization permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>OAuth 1.0: The First Step Toward Secure Authorization</h3>\n<p>OAuth 1.0 introduced a token-based system to eliminate this need for credential sharing. Users could now grant limited access to their data via tokens. However, OAuth 1.0 had these limitations:</p>\n<ul>\n<li>Challenging to implement as every API request required cryptographic signatures.</li>\n<li>Difficult to adapt to new use cases, such as mobile apps.</li>\n<li>Cumbersome to extend sessions as there were no standardized tokens.</li>\n</ul>\n<h3 id=\"oauth-20-a-more-flexible-and-scalable-solution\" style=\"position:relative;\"><a href=\"#oauth-20-a-more-flexible-and-scalable-solution\" aria-label=\"oauth 20 a more flexible and scalable solution permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>OAuth 2.0: A More Flexible and Scalable Solution</h3>\n<p>OAuth 2.0 was not just an upgrade—it was a complete rewrite designed to be more developer-friendly, scalable, and secure. </p>\n<p>Key improvements included:</p>\n<ul>\n<li>Access tokens replaced API request signing, thereby reducing complexity.</li>\n<li>OAuth 2.0 introduced different grant types for different use cases, helping reach mobile app users.</li>\n<li>Seamless authorization flows with fewer steps for users, improving overall experience.</li>\n<li>Standardized refresh tokens allowed maintaining access without storing credentials.</li>\n</ul>\n<p>With these improvements, OAuth 2.0 became the industry standard for authorization, used by platforms like Google, Facebook, and Microsoft.</p>\n<h3 id=\"key-differences-between-oauth-and-oauth20\" style=\"position:relative;\"><a href=\"#key-differences-between-oauth-and-oauth20\" aria-label=\"key differences between oauth and oauth20 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Key Differences Between OAuth and OAuth2.0</h3>\n<table>\n  <tr>\n   <td><strong>Feature</strong>\n   </td>\n   <td><strong>OAuth 1.0</strong>\n   </td>\n   <td><strong>OAuth 2.0</strong>\n   </td>\n  </tr>\n  <tr>\n   <td><strong>Architecture</strong>\n   </td>\n   <td>More complex, requires cryptographic signatures for every request.\n   </td>\n   <td>Simpler, uses access tokens for authorization.\n   </td>\n  </tr>\n  <tr>\n   <td><strong>Security</strong>\n   </td>\n   <td>Relies on request signing and shared secrets for security.\n<p>\nMedium\n   </td>\n   <td>Focuses on token-based security with various grant types.\n<p>\nHigh (if implemented correctly)\n   </td>\n  </tr>\n  <tr>\n   <td><strong>Mobile Support</strong>\n   </td>\n   <td>Less suitable for mobile apps due to complexity.\n   </td>\n   <td>Designed with mobile apps in mind, offering simpler flows.\n   </td>\n  </tr>\n  <tr>\n   <td><strong>Token Handling</strong>\n   </td>\n   <td>Uses request tokens and access tokens, requiring more steps.\n   </td>\n   <td>Uses access tokens, refresh tokens, and authorization codes, depending on the grant type.\n   </td>\n  </tr>\n  <tr>\n   <td><strong>Scalability</strong>\n   </td>\n   <td>More challenging to scale due to complex signature requirements.\n   </td>\n   <td>Highly scalable and flexible, supporting various use cases.\n   </td>\n  </tr>\n  <tr>\n   <td><strong>User Experience</strong>\n   </td>\n   <td>Can be more cumbersome for users due to multiple steps.\n   </td>\n   <td>Offers smoother user experience with simpler authorization flows.\n   </td>\n  </tr>\n</table>\n<p><a href=\"https://www.loginradius.com/resource/whitepaper/secure-api-using-oauth2\"><img src=\"/dce2d7af3a212b2cf75c6b810d4444e2/authentication-authorization-and-encryption.webp\" alt=\"Image showing free loginradius guide named A quick guide to authentication, authorization, and encryption for enterprises.\"></a></p>\n<h2 id=\"how-oauth-20-works\" style=\"position:relative;\"><a href=\"#how-oauth-20-works\" aria-label=\"how oauth 20 works permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>How OAuth 2.0 Works</h2>\n<p><strong>The following parties are important to understand the process:</strong></p>\n<p><strong>1. User (Resource owner)</strong>: Usually the end-user who has the data and grants permission.</p>\n<p><strong>2. Client:</strong> The service or application seeking access to the user’s data.</p>\n<p><strong>3. Authorization Server:</strong> The system that verifies the users and issues access tokens.</p>\n<p><strong>4. Resource Server:</strong> The service or application that holds the user’s data and grants access only when a valid token is available.</p>\n<h3 id=\"basic-oauth-20-flow\" style=\"position:relative;\"><a href=\"#basic-oauth-20-flow\" aria-label=\"basic oauth 20 flow permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Basic OAuth 2.0 Flow:</h3>\n<ol>\n<li>The client seeks permission from the user to authorize access.</li>\n<li>The user is taken to the Authorization Server to grant or deny access.</li>\n<li>If approved, the Authorization Server provides an authorization code to the client.</li>\n<li>The client utilizes the authorization code to acquire an access token from the authorization server.</li>\n<li>The client uses the access token to request protected data from the Resource Server.</li>\n</ol>\n<p>This approach guarantees that the applications receive the exact permissions required from the resource owner without ever accessing the password.</p>\n<p><img src=\"/e03ffce0e22ba4305d638cf9141da59e/oauth2-0-authorization-flow.webp\" alt=\"OAuth 2.0 authorization flow showing steps from user consent to access token and protected data request.\"></p>\n<h2 id=\"oauth-20-access-tokens-and-authorization-code\" style=\"position:relative;\"><a href=\"#oauth-20-access-tokens-and-authorization-code\" aria-label=\"oauth 20 access tokens and authorization code permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>OAuth 2.0 Access Tokens and Authorization Code</h2>\n<p>The access token is a temporary key that allows an application to access resources. It gets issued after a successful authorization code exchange and has an expiration time for security purposes. It is often paired with a refresh token, which allows for extended access without re-authentication.</p>\n<h2 id=\"getting-started-with-oauth-20-using-loginradius\" style=\"position:relative;\"><a href=\"#getting-started-with-oauth-20-using-loginradius\" aria-label=\"getting started with oauth 20 using loginradius permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Getting Started with OAuth 2.0 Using LoginRadius</h2>\n<p>Ready to implement OAuth 2.0? LoginRadius makes it easy to get started in just a few steps.</p>\n<h3 id=\"1-set-up-your-application\" style=\"position:relative;\"><a href=\"#1-set-up-your-application\" aria-label=\"1 set up your application permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>1. Set Up Your Application</h3>\n<p>Log into the<a href=\"https://accounts.loginradius.com/auth.aspx?return_url=https://console.loginradius.com/login&#x26;action=register\"> LoginRadius Admin Console</a> and go to <strong>Applications > Apps</strong>. Click <strong>Add Apps</strong>, name your app, choose <strong>OAuth 2.0</strong> as the protocol, and select the appropriate app type (e.g., Native, SPA, Web, or M2M). Hit <strong>CREATE</strong> to generate the config.</p>\n<p><img src=\"/88d353f88094b658f08d7f0d6a2623a3/openID-connect.webp\" alt=\"LoginRadius dashboard showing the interface to create a new application with OAuth 2.0 or OpenID Connect and various app types.\"></p>\n<h3 id=\"2-configure-oauth-settings\" style=\"position:relative;\"><a href=\"#2-configure-oauth-settings\" aria-label=\"2 configure oauth settings permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>2. Configure OAuth Settings</h3>\n<p>Fill in key fields like:</p>\n<ul>\n<li><strong>Client ID &#x26; Secret</strong> – credentials for your app </li>\n<li><strong>Grant Types</strong> – select one or more flows (Authorization Code, PKCE, etc.) </li>\n<li><strong>Redirect URLs &#x26; CORS Origins</strong> – for secure callback and cross-origin access </li>\n<li><strong>Token Expiry &#x26; Reauthentication</strong> – define token lifespan and re-login behavior </li>\n</ul>\n<p>Click <strong>Save</strong> when done.</p>\n<h3 id=\"3-enable-identity-providers\" style=\"position:relative;\"><a href=\"#3-enable-identity-providers\" aria-label=\"3 enable identity providers permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>3. Enable Identity Providers</h3>\n<p>Toggle on the login options (social or custom) your app will support. This gives users flexibility to sign in with their preferred IDP.</p>\n<h3 id=\"4-refresh-tokens-when-needed\" style=\"position:relative;\"><a href=\"#4-refresh-tokens-when-needed\" aria-label=\"4 refresh tokens when needed permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>4. Refresh Tokens When Needed</h3>\n<p>Use the refresh token API to renew access tokens without making users log in again. Just pass the client<em>id, grant</em>type, and refresh_token in a POST request.</p>\n<p>LoginRadius supports all major OAuth 2.0 flows, making it easy to build secure, scalable login across apps, APIs, and devices.  </p>\n<p>Do check our <a href=\"https://www.loginradius.com/docs/single-sign-on/federated-sso/oauth-2.0/overview/?q=oauth\">technical documentation </a>covers everything in detail—from authorization flows to token handling.</p>\n<h2 id=\"what-is-an-authorization-grant-and-what-are-the-key-types\" style=\"position:relative;\"><a href=\"#what-is-an-authorization-grant-and-what-are-the-key-types\" aria-label=\"what is an authorization grant and what are the key types permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What is an Authorization Grant, and What Are the Key Types?</h2>\n<p><strong>OAuth 2.0</strong> offers different ways (grant types) for applications to obtain an access token, depending on their needs:</p>\n<ul>\n<li><strong>Authorization Code Grant</strong>: This is intended for web and mobile apps as it mandates a code exchange for security.</li>\n<li><strong>Implicit Grant</strong>: A less complex flow that is not recommended anymore for security reasons.</li>\n<li><strong>Client Credentials Grant</strong>: This is designed for appliance-to-appliance communications.</li>\n<li><strong>Resource Owner Password Credentials Grant</strong>: This allows users to log in with their credentials, although it is not very popular because of security challenges.</li>\n<li><strong>Refresh Token Grant</strong>: It allows maintaining login for a user for an extended period without them having to log in again.</li>\n</ul>\n<h2 id=\"why-your-business-needs-oauth-20\" style=\"position:relative;\"><a href=\"#why-your-business-needs-oauth-20\" aria-label=\"why your business needs oauth 20 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Why Your Business Needs OAuth 2.0</h2>\n<p>Safeguarding sensitive information should be a top priority in today’s digital world, and OAuth 2.0 makes it easier to minimize risks associated with security breaches by limiting applications to only the information they have access to. </p>\n<p>Businesses that manage large quantities of data or function in highly regulated markets need compliant OAuth 2.0 implementations to maintain trust and compliance. Implementing an OAuth 2.0 system brings the following advantages:</p>\n<ul>\n<li><strong>Better Security:</strong> Organizations can eliminate unauthorized access to sensitive information by reducing the use of passwords and utilizing tokens instead, making their security measures more effective.</li>\n<li><strong>Improved User Experience:</strong> Users can easily simplify the authentication process by easily granting or denying access to different applications.</li>\n<li><strong>Scalability:</strong> OAuth 2.0 is widely adopted by numerous services ranging from Google to Facebook as it enables use across a wide range of platforms.</li>\n<li><strong>Flexibility:</strong> Consistent access across various devices and platforms is guaranteed as OAuth 2.0 works on numerous devices and enables multiple environments.</li>\n</ul>\n<h2 id=\"conclusion\" style=\"position:relative;\"><a href=\"#conclusion\" aria-label=\"conclusion permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Conclusion</h2>\n<p>OAuth 2.0 has become the go-to authorization option due to its versatile support of multi-services, APIs, and websites and its capacity to ease secure access. </p>\n<p>Leveraging platforms like LoginRadius makes the design and maintenance of an OAuth 2.0 workflow much easier. It simplifies the authorization process for your users and your business's security, regardless if your company is using web apps, mobile apps, or APIs.</p>\n<p>Contact us today and book a live participation demo to see how you can improve your security infrastructure. Start here: <a href=\"https://www.loginradius.com/contact-us\">to book a live demo</a>. </p>\n<h2 id=\"faqs\" style=\"position:relative;\"><a href=\"#faqs\" aria-label=\"faqs permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><strong>FAQs</strong></h2>\n<h3 id=\"1-what-is-open-authorization\" style=\"position:relative;\"><a href=\"#1-what-is-open-authorization\" aria-label=\"1 what is open authorization permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><strong>1. What is Open Authorization?</strong></h3>\n<p><strong>A:</strong> Open Authorization (OAuth) is an open-standard authorization framework that allows applications to access a user's data without exposing their credentials. Instead of sharing passwords, OAuth uses access tokens to grant limited and secure access to resources. </p>\n<h3 id=\"2-what-are-the-key-components-of-oauth2\" style=\"position:relative;\"><a href=\"#2-what-are-the-key-components-of-oauth2\" aria-label=\"2 what are the key components of oauth2 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><strong>2. What are the key components of OAuth2?</strong></h3>\n<p><strong>A:</strong> The key components of OAuth 2.0 include User aka Resource Owner, Client (Application), Authorization Server, Resource Server, and Access Token</p>\n<h3 id=\"3-what-is-the-auth-token\" style=\"position:relative;\"><a href=\"#3-what-is-the-auth-token\" aria-label=\"3 what is the auth token permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><strong>3. What is the auth token?</strong></h3>\n<p><strong>A:</strong> An auth token (authentication token) is a digital credential used to verify a user's identity and grant access to a system without requiring repeated logins. It is typically a temporary, encrypted string issued by an authentication server after a successful login. Common types include OAuth 2.0 access tokens and JWT (JSON Web Tokens).</p>\n<style class=\"grvsc-styles\">\n  .grvsc-container {\n    overflow: auto;\n    -webkit-overflow-scrolling: touch;\n    padding-top: 1rem;\n    padding-top: var(--grvsc-padding-top, var(--grvsc-padding-v, 1rem));\n    padding-bottom: 1rem;\n    padding-bottom: var(--grvsc-padding-bottom, var(--grvsc-padding-v, 1rem));\n    border-radius: 8px;\n    border-radius: var(--grvsc-border-radius, 8px);\n    font-feature-settings: normal;\n  }\n  \n  .grvsc-code {\n    display: inline-block;\n    min-width: 100%;\n  }\n  \n  .grvsc-line {\n    display: inline-block;\n    box-sizing: border-box;\n    width: 100%;\n    padding-left: 1.5rem;\n    padding-left: var(--grvsc-padding-left, var(--grvsc-padding-h, 1.5rem));\n    padding-right: 1.5rem;\n    padding-right: var(--grvsc-padding-right, var(--grvsc-padding-h, 1.5rem));\n  }\n  \n  .grvsc-line-highlighted {\n    background-color: var(--grvsc-line-highlighted-background-color, transparent);\n    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, transparent);\n  }\n  \n</style>","frontmatter":{"date":"March 27, 2025","updated_date":null,"title":"A comprehensive guide to OAuth 2.0 ","tags":["Oauth","Authorization Code Flow","Authorization","Authentication"],"coverImage":{"childImageSharp":{"fluid":{"aspectRatio":1,"src":"/static/10110df34137352f90a286528d35df2e/58556/what-is-oauth2-0.webp","srcSet":"/static/10110df34137352f90a286528d35df2e/61e93/what-is-oauth2-0.webp 200w,\n/static/10110df34137352f90a286528d35df2e/1f5c5/what-is-oauth2-0.webp 400w,\n/static/10110df34137352f90a286528d35df2e/58556/what-is-oauth2-0.webp 800w,\n/static/10110df34137352f90a286528d35df2e/99238/what-is-oauth2-0.webp 1200w,\n/static/10110df34137352f90a286528d35df2e/7c22d/what-is-oauth2-0.webp 1600w,\n/static/10110df34137352f90a286528d35df2e/a6559/what-is-oauth2-0.webp 4167w","sizes":"(max-width: 800px) 100vw, 800px"}}},"author":{"id":"Kundan Singh","github":null,"avatar":null}}}},{"node":{"fields":{"slug":"/engineering/authorization-code-flow-oauth/"},"html":"<p>The Authorization Code Flow for OAuth 2.0 is targeted at web applications that have a server-side component, which allows the client secret for the authorization server to be kept secret (confidential client). Typically, authorization servers will require a secret to be used when making authentication requests if more sensitive data is wanted, such as personal data or refresh tokens. Without it, you would be restricted to following the Implicit flow for <a href=\"https://www.loginradius.com/docs/single-sign-on/tutorial/federated-sso/oauth-2-0/oauth-2-0-overview/\">OAuth 2.0</a>, which only returns an access token from the authorization server.</p>\n<p>In the Authorization Code flow, the server-side component of the web application can freely manage the user's session upon authenticating with the authorization server without revealing anything about the authorization server's response (such as personal data or refresh token) to the end-user.</p>\n<h3 id=\"overview\" style=\"position:relative;\"><a href=\"#overview\" aria-label=\"overview permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Overview</h3>\n<p><img src=\"/2dff0bde50072028b53275952ba8fbb8/acf.webp\" alt=\"Authorization Code Flow Diagram\"></p>\n<p>The flow illustrated above aims to provide a rough overview of a typical Authorization Code workflow:</p>\n<ol>\n<li>The Client-Server attempts to access a resource that requires authorization that it does not have. It redirects the user to the authorization server for authentication.</li>\n<li>The Authorization Server authenticates the user by asking for their login credentials. The server determines if the user should be granted or denied their request.</li>\n<li>If the User is determined to be authentic, an Authorization Code is issued and returned to the User Client. This code is used to retrieve an access token from the Authorization Server.</li>\n<li>The retrieved Authorization Code is sent to the Client-Server. </li>\n<li>The Client-Server makes a POST request to the Authorization Server, containing its client key, secret, and Authorization Code.</li>\n<li>The Authorization Server verifies the key, secret and code, and issues an ID Token and access token. The ID Token is a JWT that is typically used to store user data from the Authorization Server.</li>\n<li>The Client-Server receives and processes the ID token and access token. The access token is then kept in the Client-Server, which can request resources on behalf of the User Client without exposing the token itself.</li>\n</ol>\n<p>So you might ask yourself what the whole point of the Authorization Code is. At first glance, it would seem that the code is issued, only to be returned to exchange for an access token. The code is what allows us to keep the token hidden away from the User Client, which could be potentially exposed to malicious agents seeking to steal the token for nefarious means. </p>\n<p>In cases where you'd like the Authorization Server to return the access token immediately, you would use the Implicit flow for OAuth 2.0. Most authorization servers will limit the amount of data that can be returned using this flow; the OAuth 2.0 spec recommends limited scopes and short lifespans for tokens returned using this flow.</p>\n<style class=\"grvsc-styles\">\n  .grvsc-container {\n    overflow: auto;\n    -webkit-overflow-scrolling: touch;\n    padding-top: 1rem;\n    padding-top: var(--grvsc-padding-top, var(--grvsc-padding-v, 1rem));\n    padding-bottom: 1rem;\n    padding-bottom: var(--grvsc-padding-bottom, var(--grvsc-padding-v, 1rem));\n    border-radius: 8px;\n    border-radius: var(--grvsc-border-radius, 8px);\n    font-feature-settings: normal;\n  }\n  \n  .grvsc-code {\n    display: inline-block;\n    min-width: 100%;\n  }\n  \n  .grvsc-line {\n    display: inline-block;\n    box-sizing: border-box;\n    width: 100%;\n    padding-left: 1.5rem;\n    padding-left: var(--grvsc-padding-left, var(--grvsc-padding-h, 1.5rem));\n    padding-right: 1.5rem;\n    padding-right: var(--grvsc-padding-right, var(--grvsc-padding-h, 1.5rem));\n  }\n  \n  .grvsc-line-highlighted {\n    background-color: var(--grvsc-line-highlighted-background-color, transparent);\n    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, transparent);\n  }\n  \n</style>","frontmatter":{"date":"March 24, 2021","updated_date":null,"title":"Guide to Authorization Code Flow for OAuth 2.0","tags":["Oauth","Authorization Code Flow"],"coverImage":{"childImageSharp":{"fluid":{"aspectRatio":1.492537313432836,"src":"/static/18d405bfac70941af3b7962d3d79073c/58556/unsplash.webp","srcSet":"/static/18d405bfac70941af3b7962d3d79073c/61e93/unsplash.webp 200w,\n/static/18d405bfac70941af3b7962d3d79073c/1f5c5/unsplash.webp 400w,\n/static/18d405bfac70941af3b7962d3d79073c/58556/unsplash.webp 800w,\n/static/18d405bfac70941af3b7962d3d79073c/99238/unsplash.webp 1200w","sizes":"(max-width: 800px) 100vw, 800px"}}},"author":{"id":"Nick Chim","github":"nickc95","avatar":null}}}}]}},"pageContext":{"tag":"Authorization Code Flow"}},"staticQueryHashes":["1171199041","1384082988","2100481360","23180105","528864852"]}