{"id":11260,"date":"2021-06-22T00:00:43","date_gmt":"2021-06-22T07:00:43","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/?p=11260"},"modified":"2025-06-13T20:08:49","modified_gmt":"2025-06-14T03:08:49","slug":"oauth-2-oidc-fundamentals-authentication-authorization","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/oauth-2-oidc-fundamentals-authentication-authorization\/","title":{"rendered":"OAuth 2.0 &amp; OIDC Fundamentals for Authentication &amp; Authorization [Part 1 of 3]"},"content":{"rendered":"<p><strong>Developers and architects<\/strong> simply can&#8217;t build modern applications without running into issues of authorization and authentication. <\/p>\n<p><a href=\"https:\/\/oauth.net\/2\/\" target=\"_blank\" rel=\"noopener\">OAuth 2.0<\/a>\u00a0<span style=\"font-weight: 400\">is an industry standard for \u201cdelegated authorization\u201d which is the ability to provide an application or client access to data or features offered by another app or service. OAuth 2.0 focuses on authorization and is not prescriptive about authentication.<\/span>\u00a0<a href=\"https:\/\/openid.net\/connect\/\" target=\"_blank\" rel=\"noopener\">OpenID Connect (OIDC)<\/a> adds a standards-based authentication layer on top of OAuth 2.0.<\/p>\n<p>To put this in context, <a href=\"https:\/\/docs.couchbase.com\/sync-gateway\/current\/authentication-users.html?ref=blog\" target=\"_blank\" rel=\"noopener\">Couchbase Sync Gateway supports various forms of client authentication<\/a>. <em>Clients<\/em> might be Couchbase Lite clients that sync data with the Sync Gateway over the Internet using a websocket-based <a href=\"https:\/\/docs.couchbase.com\/sync-gateway\/current\/sync-using-app.html?ref=blog\" target=\"_blank\" rel=\"noopener\">replication protocol<\/a>, or they could be web frontend or mobile apps that are accessing the Sync Gateway through the <a href=\"https:\/\/docs.couchbase.com\/sync-gateway\/current\/rest-api.html?ref=blog\" target=\"_blank\" rel=\"noopener\">public REST endpoint<\/a>. One of the more popular Couchbase Sync Gateway client authentication mechanisms is OIDC.<\/p>\n<p>In this post, we will cover the fundamentals of OAuth 2.0 and OIDC for authentication and authorization. I will discuss two common flows, namely the <a href=\"https:\/\/openid.net\/specs\/openid-connect-implicit-1_0.html\" target=\"_blank\" rel=\"noopener\">Implicit Flow<\/a> and the <a href=\"https:\/\/openid.net\/specs\/openid-connect-core-1_0.html\" target=\"_blank\" rel=\"noopener\">Authorization Code Flow<\/a>. A basic understanding of the flows should hopefully provide you with sufficient background for understanding how to use OIDC-based authentication within the context of Sync Gateway client authentication. More on that in a future blog post, so stay tuned!<\/p>\n<p>In order to understand OIDC, we first need to understand OAuth 2.0. That\u2019s because, as an authentication framework, OIDC is built on top of OAuth 2.0.<\/p>\n<h2>An OAuth 2.0 Primer<\/h2>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/oauth.net\/2\/\" target=\"_blank\" rel=\"noopener\">OAuth 2.0<\/a> is an industry standard for delegated authorization, and there are a number of <a href=\"https:\/\/en.wikipedia.org\/wiki\/List_of_OAuth_providers\" target=\"_blank\" rel=\"noopener\">OAuth providers<\/a> on the market.<\/p>\n<p>For example, consider the &#8220;Login with Facebook&#8221; button that powers a number of web and mobile apps. This is implemented using OAuth 2.0.<\/p>\n<p>Here\u2019s a <em>simplified<\/em> view of what goes on behind the scenes. I am describing below what is referred to as the <a href=\"https:\/\/datatracker.ietf.org\/doc\/html\/rfc6749#section-1.3.1\" target=\"_blank\" rel=\"noopener\">Authorization Code Flow<\/a>. There is an alternative &#8220;Implicit Flow&#8221; as well which is more prevalent when used in the context of OIDC.<\/p>\n<h3>Prerequisites<\/h3>\n<p>&nbsp;<\/p>\n<p>First, the app\/client must be registered with the Authorization Server. The registration process results in the generation of a <code>client_id<\/code> and a <code>client_secret<\/code> which must then be configured on the app\/client requesting authentication.<\/p>\n<p><a href=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/05\/oauth2-auth-code.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-11246\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/05\/oauth2-auth-code.png\" alt=\"OAuth2 Authorization Flow\" width=\"800\" height=\"425\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/05\/oauth2-auth-code.png 800w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/05\/oauth2-auth-code-300x159.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/05\/oauth2-auth-code-768x408.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/05\/oauth2-auth-code-20x11.png 20w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/a><\/p>\n<ul>\n<li style=\"list-style-type: none\">\n<ul>\n<li>When the user (a.k.a., <a href=\"https:\/\/datatracker.ietf.org\/doc\/html\/rfc6749\" target=\"_blank\" rel=\"noopener\">&#8220;Resource Owner&#8221;<\/a> in OAuth 2.0 speak) clicks on the <em>Login with Facebook<\/em> button on their favorite app, the app sends an <em>Authorization Request<\/em> to the login URL of the Authorization Server. In our example, the Authorization Server is Facebook. The Authorization Request includes a number of parameters. For brevity, I am not including the complete list of parameters which can be found in <a href=\"https:\/\/datatracker.ietf.org\/doc\/html\/rfc6749#section-4.1.1\" target=\"_blank\" rel=\"noopener\">RFC6749<\/a>. At a minimum, the request must include the following parameters:\n<ul>\n<li><code>client_id<\/code> which uniquely identifies the app to the Authorization Server<\/li>\n<li><code>response_type<\/code> that must be specified as <code>code<\/code> indicating that the client expects an Authorization Code<\/li>\n<li><code>request_uri<\/code> that specifies the URL that the Authorization Server must redirect control to following authentication<\/li>\n<\/ul>\n<\/li>\n<li>The Authorization Server (Facebook) prompts the user to enter their username and password and (optionally) answer a bunch of security questions that are required to authenticate the user.<\/li>\n<li>Once authenticated, the user is then (optionally) presented with a &#8220;resource consent form&#8221; listing the set of Facebook resources (such as the user\u2019s public profile) that the app wants access to.\n<ul>\n<li>The set of resources presented in the consent form is specified via a <code>scope<\/code> parameter in the initial Authorization Request to the Authorization Server.<\/li>\n<\/ul>\n<\/li>\n<li>Once the user authorizes access to the requested resources, the user is redirected back to the app with an Authorization Code.\n<ul>\n<li>The URL which the Authorization Server redirects the user to is specified via the <code>redirect_uri<\/code> parameter which is also included in the initial Authorization Request.<\/li>\n<\/ul>\n<\/li>\n<li>The app\/client then exchanges the authorization code with the Authorization Server for an opaque <em>access token<\/em> (or <em>refresh token<\/em>), passing in the <code>client_id<\/code> and <code>client_secret<\/code> as part of the request.<\/li>\n<li>The app can then access the requested resources on Facebook using the access token.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>Confused? Don\u2019t worry, we will be revisiting this again in the context of OIDC.<\/p>\n<h2>What Is OpenID Connect (OIDC) ?<\/h2>\n<p>&nbsp;<\/p>\n<p>The main goal of OAuth 2.0 is <a href=\"https:\/\/tools.ietf.org\/id\/draft-barnes-oauth-model-01.html\" target=\"_blank\" rel=\"noopener\">delegated authorization<\/a>. In other words, as we saw earlier, the primary purpose of OAuth 2.0 is to grant an app access to data owned by another app.<\/p>\n<p>OAuth 2.0 does not focus on authentication, and as such, any authentication implementation using OAuth 2.0 is non-standard. That\u2019s where OpenID Connect (OIDC) comes in. OIDC adds a standards-based authentication layer on top of OAuth 2.0.<\/p>\n<p>The Authorization Server in the OAuth 2.0 flows now assumes the role of <em>Identity Server<\/em> (or <em>OIDC Provider<\/em>). The underlying protocol is almost identical to OAuth 2.0 except that the Identity Server delivers an <em>Identity Token<\/em> (ID Token) to the requesting app. The Identity Token is a standard way of encoding the claims about the authentication of the user. We will talk more about identity tokens later.<\/p>\n<p>I will describe two popular OIDC flows here: Implicit Flow and Authorization Code Flow.<\/p>\n<h3>Prerequisites<\/h3>\n<p>&nbsp;<\/p>\n<p>For both these flows, the app\/client must be registered with the Authorization Server. The registration process results in the generation of a <code>client_id<\/code> and a <code>client_secret<\/code> which must then be configured on the app\/client requesting authentication.<\/p>\n<h3>OIDC Implicit Flow<\/h3>\n<p>&nbsp;<\/p>\n<p>The OIDC <a href=\"https:\/\/openid.net\/specs\/openid-connect-core-1_0.html#ImplicitFlowAuth\" target=\"_blank\" rel=\"noopener\">Implicit Flow<\/a> is the simpler of the two and is recommended for use in Couchbase Lite client authentication with Sync Gateway which we will talk about more in my next blog post.<\/p>\n<p>Once again, we will use <em>Login with Facebook<\/em> as an example to illustrate the flow.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/05\/oidc-implicit.png\" alt=\"OIDC Implicit Flow\" \/><\/p>\n<ul>\n<li style=\"list-style-type: none\">\n<ul>\n<li>When the user clicks on the <em>Login with Facebook<\/em> button on their favorite app, the app sends an Authentication Request to the login URL of the Authorization Server or Identity Server. In our example, the Authorization Server is Facebook.\n<ul>\n<li>The Authentication Request includes a number of parameters. For brevity, I am not including the complete list of all parameters which <a href=\"https:\/\/openid.net\/specs\/openid-connect-core-1_0.html#ImplicitAuthRequest\" target=\"_blank\" rel=\"noopener\">can be found in the OIDC spec<\/a>. At a minimum, the request must include the following parameters:\n<ul>\n<li><code>client_id<\/code> which uniquely identifies the app to the Authorization Server<\/li>\n<li><code>response_type<\/code> that must be specified as <code>id_token<\/code> indicating that the client expects an ID Token.<\/li>\n<li><code>scope<\/code> that <strong>must<\/strong> contain the <code>openid<\/code> scope value, in addition to an optional list of resources that the app is requesting access to<\/li>\n<li><code>request_uri<\/code> that specifies the URL that the Authorization must redirect control to following authentication<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>The Identity Server (Facebook) then prompts the user to enter their username and password and (optionally) answer a bunch of security questions that are required to authenticate the user.<\/li>\n<li>Once authenticated, the user is then (optionally) presented with a &#8220;resource consent form&#8221; listing the set of Facebook resources (such as the user\u2019s public profile) that the app wants access to.\n<ul>\n<li>The set of resources presented in the consent form is specified via the <code>scope<\/code> parameter which was included in the initial Authentication Request to the Authorization Server.<\/li>\n<\/ul>\n<\/li>\n<li>Once the user authorizes access to the requested resources, the user is redirected back to the app with an <a href=\"https:\/\/openid.net\/specs\/openid-connect-core-1_0.html#ImplicitIDToken\" target=\"_blank\" rel=\"noopener\">Identity Token<\/a> and optionally an Access Token\n<ul>\n<li>The URL which the Authentication Server redirects the user to is specified via the <code>redirect_uri<\/code> parameter which is also included in the initial Authentication Request.<\/li>\n<\/ul>\n<\/li>\n<li>The app then validates the Identity Token per criteria specified in the <a href=\"https:\/\/openid.net\/specs\/openid-connect-core-1_0.html#ImplicitIDTValidation\" target=\"_blank\" rel=\"noopener\">OIDC spec<\/a> and retrieves the identity of the authenticated user.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h3>OIDC Authorization Code Flow<\/h3>\n<p>&nbsp;<\/p>\n<p>The OIDC <a href=\"https:\/\/openid.net\/specs\/openid-connect-core-1_0.html#CodeFlowAuth\" target=\"_blank\" rel=\"noopener\">Authorization Code Flow<\/a> is very similar to the OAuth 2.0 Authorization Code Flow described earlier.<\/p>\n<p>Once again, we will use <em>Login with Facebook<\/em> as an example to illustrate the flow.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/05\/oidc-authflow.png\" alt=\"OIDC Auth code flow\" \/><\/p>\n<ul>\n<li style=\"list-style-type: none\">\n<ul>\n<li>When the user clicks on the <em>Login with Facebook<\/em> button on their favorite app, the app sends an Authentication Request to the login URL of Authorization Server or Identity Server. In our example, the Authorization Server is Facebook.\n<ul>\n<li>The Authentication Request includes a number of parameters. For brevity, I am not including the complete list of all parameters which can be found in <a href=\"https:\/\/openid.net\/specs\/openid-connect-core-1_0.html#ImplicitAuthRequest\" target=\"_blank\" rel=\"noopener\">OIDC spec<\/a>. At a minimum, the request must include the following parameters:\n<ul>\n<li><code>client_id<\/code> which uniquely identifies the app to the Authorization Server<\/li>\n<li><code>response_type<\/code> that must be specified as <code>code<\/code> indicating that the client expects an Authorization Code.<\/li>\n<li><code>scope<\/code> that <strong>must<\/strong> contain the <code>openid<\/code> scope value, in addition to an optional list of resources that app is requesting access to<\/li>\n<li><code>request_uri<\/code> that specifies the URL that the Authorization must redirect control to following authentication<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>The Identity Server (Facebook) then prompts the user to enter their username and password and (optionally) answer a bunch of security questions that are required to authenticate the user.<\/li>\n<li>Once authenticated, the user is then (optionally) presented with a &#8220;resource consent form&#8221; listing the set of Facebook resources (such as the user\u2019s public profile) that the app wants access to.\n<ul>\n<li>The set of resources presented in the consent form is specified via the <code>scope<\/code> parameter which is also included in the initial Authentication Request to the Authorization Server.<\/li>\n<\/ul>\n<\/li>\n<li>Once the user authorizes access to the requested resources, the user is redirected back to the app with an <a href=\"https:\/\/datatracker.ietf.org\/doc\/html\/rfc6749#section-1.3.1\" target=\"_blank\" rel=\"noopener\">Authorization Code<\/a>\n<ul>\n<li>The URL which the Authorization Server redirects the user to is specified via the <code>redirect_uri<\/code> parameter which is also included in the initial Authorization Request.<\/li>\n<\/ul>\n<\/li>\n<li>The app\/client then exchanges the authorization code with the Authorization Server for an <a href=\"https:\/\/openid.net\/specs\/openid-connect-core-1_0.html#ImplicitIDToken\" target=\"_blank\" rel=\"noopener\">Identity Token<\/a> and an opaque Access Token, passing in the <code>client_id<\/code> and <code>client_secret<\/code> as part of the request.<\/li>\n<li>The app then validates the Identity Token per criteria specified in the <a href=\"https:\/\/openid.net\/specs\/openid-connect-core-1_0.html#ImplicitIDTValidation\" target=\"_blank\" rel=\"noopener\">OIDC spec<\/a> and retrieves the identity of the authenticated user.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h2>JSON Web Token (JWT)<\/h2>\n<p>&nbsp;<\/p>\n<p>A key element of OIDC is the Identity Token which is a security token that encodes the authentication claims about a user in a standard format referred to as the <a href=\"https:\/\/datatracker.ietf.org\/doc\/html\/rfc7519\" target=\"_blank\" rel=\"noopener\">JSON Web Token (JWT)<\/a>. The JWT is digitally signed.<\/p>\n<p>A &#8220;claim&#8221; is an assertion about the user. Here is an example of a JWT which has a typical set of claims.<\/p>\n<pre class=\"lang:js decode:true \" title=\"Sample JWT\">{\r\n  \"sub\": \"AItOawmwtWwcT0k51BayewNvutrJUqsvl6qs7A4\",\r\n  \"name\": \"Priya Rajagopal\",\r\n  \"email\": \"priya.rajagopal@example.com\",\r\n  \"iss\": \"https:\/\/pk-demo.okta.com\/OAuth 2.0\/default\",\r\n  \"aud\": \"WuRuBAgABMP7_w4K9L-40Jhh\",\r\n  \"iat\": 1622246311,\r\n  \"exp\": 1624838311,\r\n  \"amr\": [\r\n    \"pwd\"\r\n  ]\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n<ul>\n<li style=\"list-style-type: none\">\n<ul>\n<li><code>sub<\/code> is the user whom the JWT refers to<\/li>\n<li><code>iss<\/code> is the issuer of the JWT who also signs the JWT<\/li>\n<li><code>aud<\/code> is who the token is intended for<\/li>\n<li><code>iat<\/code> is the issued timestamp<\/li>\n<li><code>exp<\/code> is the expiration timestamp<\/li>\n<li><code>amr<\/code> refers to the authentication method used to issue token<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h2>More Resources<\/h2>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/jwt.io\/\" target=\"_blank\" rel=\"noopener\">jwt.io<\/a> is very useful to decode and verify a JWT.<\/p>\n<p>The <a href=\"https:\/\/www.oauth.com\/playground\/index.html\" target=\"_blank\" rel=\"noopener\">OIDC and OAuth playground<\/a> from Okta is a great resource for trying out the flows without actually implementing it.<\/p>\n<h2>What\u2019s Next<\/h2>\n<p>&nbsp;<\/p>\n<p>In this post we described the fundamentals of OpenID Connect (OIDC) and OAuth 2.0 flows. In next week&#8217;s post, we will discuss OIDC-based authentication in the context of Sync Gateway client authentication. Stay tuned!<\/p>\n<p>If you have questions or feedback, please leave a comment below or email me <a href=\"mailto:priya.rajagopal@couchbase.com\">priya.rajagopal@couchbase.com<\/a>. The <a href=\"https:\/\/www.couchbase.com\/forums\/?ref=blog\" target=\"_blank\" rel=\"noopener\">Couchbase Forums<\/a> are another good place to reach out with questions.<br \/>\n&nbsp;<\/p>\n<p><em>Catch up with the rest of the posts in this series on authentication and authorization:<\/p>\n<ul>\n<ul>\n<li><a href=\"https:\/\/www.couchbase.com\/blog\/oauth-2-oidc-fundamentals-authentication-authorization\/?ref=blog\" rel=\"noopener\" target=\"_blank\">OAuth 2.0 &amp; OIDC Fundamentals for Authentication &amp; Authorization [Part 1]<\/a><\/li>\n<li><a href=\"https:\/\/www.couchbase.com\/blog\/oidc-implicit-flow-client-authentication-couchbase-sync-gateway\/?ref=blog\" rel=\"noopener\" target=\"_blank\">OIDC Implicit Flow for Client Authentication in Couchbase Sync Gateway [Part 2]<\/a><\/li>\n<li><a href=\"https:\/\/www.couchbase.com\/blog\/oidc-authorization-code-flow-client-authentication-couchbase-sync-gateway\/?ref=blog\" rel=\"noopener\" target=\"_blank\">OIDC Authorization Code Flow for Client Authentication in Couchbase Sync Gateway [Part 3]<\/a><\/li>\n<\/ul>\n<\/ul>\n<p><\/em><br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Developers and architects simply can&#8217;t build modern applications without running into issues of authorization and authentication. OAuth 2.0\u00a0is an industry standard for \u201cdelegated authorization\u201d which is the ability to provide an application or client access to data or features offered [&hellip;]<\/p>\n","protected":false},"author":1423,"featured_media":11261,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[1815,7667,1810,1813,2366],"tags":[9266,9250,1261,2251,9234,1713],"ppma_author":[8948],"class_list":["post-11260","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-best-practices-and-tutorials","category-couchbase-lite","category-couchbase-mobile","category-security","category-sync-gateway","tag-authorization-code-flow","tag-implicit-flow","tag-json","tag-jwt","tag-oidc","tag-openid-connect"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.7.1 (Yoast SEO v25.7) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>OAuth 2.0 &amp; OIDC Fundamentals for Authentication &amp; Authorization [Part 1 of 3]<\/title>\n<meta name=\"description\" content=\"Discover how to implement implicit and authorization code flows for user authentication and authorization using OAuth 2.0 and OIDC alongside Couchbase.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.couchbase.com\/blog\/oauth-2-oidc-fundamentals-authentication-authorization\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"OAuth 2.0 &amp; OIDC Fundamentals for Authentication &amp; Authorization [Part 1 of 3]\" \/>\n<meta property=\"og:description\" content=\"Discover how to implement implicit and authorization code flows for user authentication and authorization using OAuth 2.0 and OIDC alongside Couchbase.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/oauth-2-oidc-fundamentals-authentication-authorization\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:published_time\" content=\"2021-06-22T07:00:43+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-14T03:08:49+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/06\/feature.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Priya Rajagopal, Senior Director, Product Management\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@rajagp\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Priya Rajagopal, Senior Director, Product Management\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/oauth-2-oidc-fundamentals-authentication-authorization\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/oauth-2-oidc-fundamentals-authentication-authorization\/\"},\"author\":{\"name\":\"Priya Rajagopal, Senior Director, Product Management\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/c2da90e57717ee4970c48a87a131ac2c\"},\"headline\":\"OAuth 2.0 &amp; OIDC Fundamentals for Authentication &amp; Authorization [Part 1 of 3]\",\"datePublished\":\"2021-06-22T07:00:43+00:00\",\"dateModified\":\"2025-06-14T03:08:49+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/oauth-2-oidc-fundamentals-authentication-authorization\/\"},\"wordCount\":1818,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/oauth-2-oidc-fundamentals-authentication-authorization\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/06\/feature.png\",\"keywords\":[\"Authorization Code Flow\",\"Implicit Flow\",\"JSON\",\"jwt\",\"OIDC\",\"OpenID Connect\"],\"articleSection\":[\"Best Practices and Tutorials\",\"Couchbase Lite\",\"Couchbase Mobile\",\"Security\",\"Sync Gateway\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/oauth-2-oidc-fundamentals-authentication-authorization\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/oauth-2-oidc-fundamentals-authentication-authorization\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/oauth-2-oidc-fundamentals-authentication-authorization\/\",\"name\":\"OAuth 2.0 &amp; OIDC Fundamentals for Authentication &amp; Authorization [Part 1 of 3]\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/oauth-2-oidc-fundamentals-authentication-authorization\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/oauth-2-oidc-fundamentals-authentication-authorization\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/06\/feature.png\",\"datePublished\":\"2021-06-22T07:00:43+00:00\",\"dateModified\":\"2025-06-14T03:08:49+00:00\",\"description\":\"Discover how to implement implicit and authorization code flows for user authentication and authorization using OAuth 2.0 and OIDC alongside Couchbase.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/oauth-2-oidc-fundamentals-authentication-authorization\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/oauth-2-oidc-fundamentals-authentication-authorization\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/oauth-2-oidc-fundamentals-authentication-authorization\/#primaryimage\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/06\/feature.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/06\/feature.png\",\"width\":1200,\"height\":628,\"caption\":\"Learn more about using various OIDC and OAuth 2.0 authentication flows with Couchbase Sync Gateway\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/oauth-2-oidc-fundamentals-authentication-authorization\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.couchbase.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"OAuth 2.0 &amp; OIDC Fundamentals for Authentication &amp; Authorization [Part 1 of 3]\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"name\":\"The Couchbase Blog\",\"description\":\"Couchbase, the NoSQL Database\",\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\",\"name\":\"The Couchbase Blog\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"width\":218,\"height\":34,\"caption\":\"The Couchbase Blog\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/c2da90e57717ee4970c48a87a131ac2c\",\"name\":\"Priya Rajagopal, Senior Director, Product Management\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/4b50a54778b979d8c345b036ab138734\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/acfb2349788955262cd069497a9e7bdb0e97c26326f2e55811e7c1174e9ef1be?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/acfb2349788955262cd069497a9e7bdb0e97c26326f2e55811e7c1174e9ef1be?s=96&d=mm&r=g\",\"caption\":\"Priya Rajagopal, Senior Director, Product Management\"},\"description\":\"Priya Rajagopal is a Senior Director of Product Management at Couchbase responsible for developer platforms for the cloud and the edge. She has been professionally developing software for over 20 years in several technical and product leadership positions, with 10+ years focused on mobile technologies. As a TISPAN IPTV standards delegate, she was a key contributor to the IPTV standards specifications. She has 22 patents in the areas of networking and platform security.\",\"sameAs\":[\"https:\/\/x.com\/rajagp\"],\"url\":\"https:\/\/www.couchbase.com\/blog\/author\/priya-rajagopalcouchbase-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"OAuth 2.0 &amp; OIDC Fundamentals for Authentication &amp; Authorization [Part 1 of 3]","description":"Discover how to implement implicit and authorization code flows for user authentication and authorization using OAuth 2.0 and OIDC alongside Couchbase.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.couchbase.com\/blog\/oauth-2-oidc-fundamentals-authentication-authorization\/","og_locale":"en_US","og_type":"article","og_title":"OAuth 2.0 &amp; OIDC Fundamentals for Authentication &amp; Authorization [Part 1 of 3]","og_description":"Discover how to implement implicit and authorization code flows for user authentication and authorization using OAuth 2.0 and OIDC alongside Couchbase.","og_url":"https:\/\/www.couchbase.com\/blog\/oauth-2-oidc-fundamentals-authentication-authorization\/","og_site_name":"The Couchbase Blog","article_published_time":"2021-06-22T07:00:43+00:00","article_modified_time":"2025-06-14T03:08:49+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/06\/feature.png","type":"image\/png"}],"author":"Priya Rajagopal, Senior Director, Product Management","twitter_card":"summary_large_image","twitter_creator":"@rajagp","twitter_misc":{"Written by":"Priya Rajagopal, Senior Director, Product Management","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/oauth-2-oidc-fundamentals-authentication-authorization\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/oauth-2-oidc-fundamentals-authentication-authorization\/"},"author":{"name":"Priya Rajagopal, Senior Director, Product Management","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/c2da90e57717ee4970c48a87a131ac2c"},"headline":"OAuth 2.0 &amp; OIDC Fundamentals for Authentication &amp; Authorization [Part 1 of 3]","datePublished":"2021-06-22T07:00:43+00:00","dateModified":"2025-06-14T03:08:49+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/oauth-2-oidc-fundamentals-authentication-authorization\/"},"wordCount":1818,"commentCount":0,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/oauth-2-oidc-fundamentals-authentication-authorization\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/06\/feature.png","keywords":["Authorization Code Flow","Implicit Flow","JSON","jwt","OIDC","OpenID Connect"],"articleSection":["Best Practices and Tutorials","Couchbase Lite","Couchbase Mobile","Security","Sync Gateway"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/oauth-2-oidc-fundamentals-authentication-authorization\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/oauth-2-oidc-fundamentals-authentication-authorization\/","url":"https:\/\/www.couchbase.com\/blog\/oauth-2-oidc-fundamentals-authentication-authorization\/","name":"OAuth 2.0 &amp; OIDC Fundamentals for Authentication &amp; Authorization [Part 1 of 3]","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/oauth-2-oidc-fundamentals-authentication-authorization\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/oauth-2-oidc-fundamentals-authentication-authorization\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/06\/feature.png","datePublished":"2021-06-22T07:00:43+00:00","dateModified":"2025-06-14T03:08:49+00:00","description":"Discover how to implement implicit and authorization code flows for user authentication and authorization using OAuth 2.0 and OIDC alongside Couchbase.","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/oauth-2-oidc-fundamentals-authentication-authorization\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/oauth-2-oidc-fundamentals-authentication-authorization\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/oauth-2-oidc-fundamentals-authentication-authorization\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/06\/feature.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/06\/feature.png","width":1200,"height":628,"caption":"Learn more about using various OIDC and OAuth 2.0 authentication flows with Couchbase Sync Gateway"},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/oauth-2-oidc-fundamentals-authentication-authorization\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"OAuth 2.0 &amp; OIDC Fundamentals for Authentication &amp; Authorization [Part 1 of 3]"}]},{"@type":"WebSite","@id":"https:\/\/www.couchbase.com\/blog\/#website","url":"https:\/\/www.couchbase.com\/blog\/","name":"The Couchbase Blog","description":"Couchbase, the NoSQL Database","publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/blog\/#organization","name":"The Couchbase Blog","url":"https:\/\/www.couchbase.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","width":218,"height":34,"caption":"The Couchbase Blog"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/c2da90e57717ee4970c48a87a131ac2c","name":"Priya Rajagopal, Senior Director, Product Management","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/4b50a54778b979d8c345b036ab138734","url":"https:\/\/secure.gravatar.com\/avatar\/acfb2349788955262cd069497a9e7bdb0e97c26326f2e55811e7c1174e9ef1be?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/acfb2349788955262cd069497a9e7bdb0e97c26326f2e55811e7c1174e9ef1be?s=96&d=mm&r=g","caption":"Priya Rajagopal, Senior Director, Product Management"},"description":"Priya Rajagopal is a Senior Director of Product Management at Couchbase responsible for developer platforms for the cloud and the edge. She has been professionally developing software for over 20 years in several technical and product leadership positions, with 10+ years focused on mobile technologies. As a TISPAN IPTV standards delegate, she was a key contributor to the IPTV standards specifications. She has 22 patents in the areas of networking and platform security.","sameAs":["https:\/\/x.com\/rajagp"],"url":"https:\/\/www.couchbase.com\/blog\/author\/priya-rajagopalcouchbase-com\/"}]}},"authors":[{"term_id":8948,"user_id":1423,"is_guest":0,"slug":"priya-rajagopalcouchbase-com","display_name":"Priya Rajagopal, Senior Director, Product Management","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/acfb2349788955262cd069497a9e7bdb0e97c26326f2e55811e7c1174e9ef1be?s=96&d=mm&r=g","author_category":"","last_name":"Rajagopal, Senior Director, Product Management","first_name":"Priya","job_title":"","user_url":"","description":"Priya Rajagopal is a Senior Director of Product Management at Couchbase responsible for developer platforms for the cloud and the edge. She has been professionally developing software for over 20 years in several technical and product leadership positions, with 10+ years focused on mobile technologies. As a TISPAN IPTV standards delegate, she was a key contributor to the IPTV standards specifications. She has 22 patents in the areas of networking and platform security."}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/11260","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/users\/1423"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/comments?post=11260"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/11260\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media\/11261"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media?parent=11260"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/categories?post=11260"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/tags?post=11260"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=11260"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}