{"id":97676,"date":"2020-12-04T11:00:00","date_gmt":"2020-12-04T09:00:00","guid":{"rendered":"https:\/\/examples.javacodegeeks.com\/?p=97676"},"modified":"2020-11-26T16:46:37","modified_gmt":"2020-11-26T14:46:37","slug":"spring-boot-and-oauth2-tutorial","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/spring-boot-and-oauth2-tutorial\/","title":{"rendered":"Spring Boot and OAuth2 Tutorial"},"content":{"rendered":"<p>In this tutorial, we will show how to integrate OAuth2 with Spring Security in a Spring Boot application.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-1-introduction\">1. Introduction<\/h2>\n<p>Many web applications use some mechanism for identifying a user, if for nothing more than to provide a personalized experience. Also, an authorization check may be required to determine if the user has the necessary access level to use the services in your application. To these ends, you must start by authenticating the user.<\/p>\n<p>Spring features a Security Framework you can apply for your authorization and authentication needs. It provides a configurable security filter chain used to protects URLs and to validate usernames and passwords.<\/p>\n<p>Traditionally, you would use an in-memory or relational database to store user credentials and roles. The current trend, however, is to use an Identity and Access Management (IAM) platform to manage digital identities and to grant access to web resources. Also, the use of an external Identity Provider (IDP) solution for user authentication has become popular. This has the added benefit of enabling Single Sign-on, making the user\u2019s experience seamless.<\/p>\n<p>These solutions are typically implemented using the OAuth 2 framework for the authorization layer and Open ID Connect (OIDC) for supplying user authentication services. OIDC is also used to obtain basic profile information about the user.<\/p>\n<p>In this example, we will show how to integrate OAuth2 with Spring Security for authentication and authorization in a Spring Boot application.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-1-1-technologies-used\">1.1 Technologies Used<\/h3>\n<ul class=\"wp-block-list\">\n<li>Eclipse IDE for Enterprise Java Developers Version: 2020-09 (4.17.0) <\/li>\n<li>Spring Tools 4 \u2013 for Spring Boot<\/li>\n<\/ul>\n<p>Spring Tools 4 for Spring Boot is a set of plugins for Eclipse that support building and running Spring Boot applications. You can add Spring Tools 4 to your existing Eclipse installation by going to the Eclipse Marketplace and searching for \u201cSpring Tools 4\u201d.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-2-spring-boot-and-oauth2-tutorial\">2. Spring Boot and OAuth2 Tutorial<\/h2>\n<h3 class=\"wp-block-heading\" id=\"h-2-1-quick-introduction-to-oauth2\">2.1 Quick Introduction to OAuth2<\/h3>\n<p>OAuth2 is a framework used by client applications to access a user\u2019s resources (with the user\u2019s consent) without exploiting the user\u2019s credentials. It performs this by using access tokens in place of usernames and passwords.<\/p>\n<p>OAuth2 defines four roles:<\/p>\n<ul class=\"wp-block-list\">\n<li>Resource Owner \u2013 The user that owns the account data to be shared, for example, an end-user employing your application.<\/li>\n<li>Resource Server \u2013 The server that hosts the user\u2019s resources including (but not limited to) credentials and profile data.<\/li>\n<li>Client Application \u2013 The application requesting resources from the resource server on behalf of the resource owner, such as a web application.<\/li>\n<li>Authorization Server \u2013 The server that will process the request to give the client application access to the owner\u2019s resources.<\/li>\n<\/ul>\n<p>Clear as mud? Hopefully, these concepts will become plainer as we proceed.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-2-2-create-the-client-application\">2.2 Create the Client Application<\/h3>\n<p>We\u2019ll start by creating the client application. Create a new Spring Starter Project using the new project wizard in Eclipse. Select \u201cSpring Web\u201d, \u201cThymeleaf\u201d, \u201cSpring Boot Actuator\u201d, and \u201cOAuth2 Client\u201d as dependencies.<\/p>\n<ul class=\"wp-block-list\">\n<li>Spring Web \u2013 adds Spring MVC and embedded Tomcat container<\/li>\n<li>Thymeleaf \u2013 used as the template engine for rendering HTML<\/li>\n<li>Spring Boot Actuator \u2013 adds endpoints for monitoring your application<\/li>\n<li>OAuth2 Client \u2013 adds Spring Security and OAuth2 client support<\/li>\n<\/ul>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"553\" height=\"781\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/oauth2-dependencies-wm.jpg\" alt=\"spring boot oauth2 - Project Dependencies\" class=\"wp-image-97685\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/oauth2-dependencies-wm.jpg 553w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/oauth2-dependencies-wm-212x300.jpg 212w\" sizes=\"(max-width: 553px) 100vw, 553px\" \/><figcaption>Project Dependencies<\/figcaption><\/figure>\n<\/div>\n<p>Click Finish.<\/p>\n<p>Start the application using the Boot Dashboard. (Alternatively, you can package the application in an executable jar file or run the \u201cmvn spring-boot:run\u201d command from the console.<\/p>\n<p>Open a browser and enter <a href=\"http:\/\/localhost:8080\/actuator\" target=\"_blank\" rel=\"noreferrer noopener\">http:\/\/localhost:8080\/actuator<\/a>.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"386\" height=\"277\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/please-sign-in-wm.jpg\" alt=\"spring boot oauth2 - Spring Sign In\" class=\"wp-image-97686\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/please-sign-in-wm.jpg 386w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/please-sign-in-wm-300x215.jpg 300w\" sizes=\"(max-width: 386px) 100vw, 386px\" \/><figcaption>Spring Sign In<\/figcaption><\/figure>\n<\/div>\n<p>Spring Security auto-configures a <code>DefaultSecurityFilterChain<\/code>, which protects all URL requests by default. To allow non-authenticated access to the actuator endpoint, we will need to configure web security. We can do this by creating a configuration class that extends <code>WebSecurityConfigurerAdapter<\/code> and implement its <code>configure(HttpSecurity http<\/code>) method.<\/p>\n<p><span style=\"text-decoration: underline\"><em>SecurityConfiguration.java<\/em><\/span><\/p>\n<pre class=\"brush:java; wrap-lines:false\">import org.springframework.context.annotation.Configuration;\nimport org.springframework.security.config.annotation.web.builders.HttpSecurity;\nimport org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;\n\n@Configuration\npublic class SecurityConfiguration extends WebSecurityConfigurerAdapter {\n\n\t@Override\n\tprotected void configure(HttpSecurity http) throws Exception {\n\t\thttp.authorizeRequests()\n\t\t\t.antMatchers(\"\/actuator\").permitAll()\n\t\t\t.anyRequest().authenticated();\n\t}\n\t\n}\n<\/pre>\n<p>The&nbsp;<code>@Configuration<\/code>&nbsp;annotation registers this as a configuration classs. We used an <code>antMatcher<\/code> to specify that the <em>\/actuator<\/em> endpoint is permitted to all. It serves as a whitelist since we then specify that any request is accessible to authenticated users only with .<code>anyRequest().authenticated()<\/code>. This is typically used as a <em>catch-all<\/em> mechanism to prevent unauthenticated access to your site.<\/p>\n<p>Restart the application.&nbsp; You will now be able to access the <em>\/actuator<\/em> endpoint.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"734\" height=\"151\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/actuator-wm.jpg\" alt=\"spring boot oauth2 - Actuator Endpoint\" class=\"wp-image-97687\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/actuator-wm.jpg 734w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/actuator-wm-300x62.jpg 300w\" sizes=\"(max-width: 734px) 100vw, 734px\" \/><figcaption>Actuator Endpoint<\/figcaption><\/figure>\n<\/div>\n<h3 class=\"wp-block-heading\" id=\"h-2-3-more-on-oauth2\">2.3 More on OAuth2<\/h3>\n<p>Access tokens are used by the client application to gain restricted access to a user resource. An access token contains information about the privileges the user consented to give to the client application. Tokens are temporary. You can use a <em>refresh token<\/em> (if provided) to request a new access token when it has expired. Access tokens are obtained from the <em>authorization server.<\/em><\/p>\n<p>A grant type flow is used to acquire an access token. OAuth 2 defines several grant types, each suited for a particular use case. The <em>authorization code<\/em> grant type is the most appropriate for server-side client applications, such as your typical web application.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>In the <em>authorization code<\/em> grant type, the client uses an authorization code to obtain an access token from the <em>authorization server<\/em>. The application <em>client id <\/em>and <em>client secret<\/em> credentials are used for interactions with the authorization server. Since the application source code is not accessible outside the client application, it is acceptable to store this information in a properties file.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-2-4-integrating-oauth2-with-spring-boot\">2.4 Integrating OAuth2 with Spring Boot<\/h3>\n<p>To use an authentication provider in a Spring Boot application three steps are required:<\/p>\n<ul class=\"wp-block-list\">\n<li>Register your application with the authentication provider<\/li>\n<li>Edit <em>applicaition.properties<\/em> or <em>application.yml<\/em> with the configuration details supplied by the provider, e.g. <em>client id<\/em> and <em>client secret<\/em><\/li>\n<li>Configure OAuth2 in your security configuration class\u2019 <code>configure(HttpSecurity http)<\/code> method<\/li>\n<\/ul>\n<p>There are many OAuth2 authentication providers from which to choose. You can use a social network that offers identity services, such as Google or GitHub. (This arrangement is sometimes referred to as a social login). There are also corporate login providers like Okta and AuthO. Spring Security contains default configurations for Google, Facebook, GitHub, and Okta. &nbsp;We will use GitHub in our first example. (You can sign up for a GitHub account at <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/join\" target=\"_blank\">https:\/\/github.com\/join<\/a>.)<\/p>\n<p>Once you have a GitHub account you can register the client application at <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/settings\/developers\" target=\"_blank\">https:\/\/github.com\/settings\/developers<\/a>.<\/p>\n<p>On the Developer setting page, select &#8220;OAuth Apps&#8221; and then click the &#8220;New OAuth App\u201d button. Enter the application name and the application\u2019s Homepage URL, (<em>http:\/\/localhost:8080<\/em>, in this example). Set the Authorization callback URL as <em>http:\/\/localhost:8080\/login\/oauth2\/code\/<\/em>.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"586\" height=\"564\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/register-oauth-app-wm.jpg\" alt=\"spring boot oauth2 - GitHub OAuth\" class=\"wp-image-97689\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/register-oauth-app-wm.jpg 586w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/register-oauth-app-wm-300x289.jpg 300w\" sizes=\"(max-width: 586px) 100vw, 586px\" \/><figcaption>GitHub OAuth Client Registration<\/figcaption><\/figure>\n<\/div>\n<p>The Authorization callback URL (aka redirection URL) is the path in the client application (our Spring Boot application) that the browser is redirected back to after the user authenticates and grants access. Spring Security uses a URI template for the aforementioned providers:<code>{baseUrl}\/login\/oauth2\/code\/{registrationId}<\/code>. The&nbsp;<em>registrationId<\/em>&nbsp;is the unique identifier of the provider, in our example, \u201cgithub\u201d. The redirect URL endpoint receives the authentication code from the provider and uses it to acquire an access token.<\/p>\n<p>Click the&nbsp;<em>Register Application<\/em> button. Copy the client id and client secret. We will use these credentials to configure our client application to use the client registration we just created.<\/p>\n<p>Open the <em>application.properties<\/em> file and add the client registration information:<\/p>\n<p><span style=\"text-decoration: underline\"><em>application.properties<\/em><\/span><\/p>\n<pre class=\"brush:plain; wrap-lines:false\">spring.security.oauth2.client.registration.github.client-id=&lt;your-client-id&gt;\nspring.security.oauth2.client.registration.github.client-secret=&lt;your-client-secret&gt;\n<\/pre>\n<p>If you use Google, Facebook, GitHub, or Okta as your authentication provider, you are only required to provide the client id and client secret as Spring Boot will use a default configuration for the other necessary properties. The property names are prefixed with \u201c<em>spring.security.oauth2.client.registration<\/em>\u201d followed by the client name, then the name of the client property. If you are using a different provider, additional properties are required. You can view the documentation for configuring your specific provider on their site.<\/p>\n<p>Next, we\u2019ll create two views, <em>home.html<\/em> and <em>classified.htm<\/em>l in the <em>\/src\/main\/resources\/templates\/<\/em> folder.<\/p>\n<p><span style=\"text-decoration: underline\"><em>home.html<\/em><\/span><\/p>\n<pre class=\"brush:xml\">&lt;!DOCTYPE html&gt;\n&lt;html xmlns:th=\"http:\/\/www.thymeleaf.org\"&gt;\n&lt;head&gt;\n&lt;meta charset=\"ISO-8859-1\"&gt;\n&lt;title&gt;Home Page&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n&lt;h2&gt;Hello!&lt;\/h2&gt;\n\n&lt;\/body&gt;\n&lt;\/html&gt;\n<\/pre>\n<p><span style=\"text-decoration: underline\"><em>classified.html<\/em><\/span><\/p>\n<pre class=\"brush:xml\">&lt;!DOCTYPE html&gt;\n&lt;html xmlns:th=\"http:\/\/www.thymeleaf.org\"&gt;\n&lt;head&gt;\n&lt;meta charset=\"ISO-8859-1\"&gt;\n&lt;title&gt;Classified&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n&lt;h2&gt;This Page is Classified!&lt;\/h2&gt;\n\n\n&lt;\/body&gt;\n&lt;\/html&gt;\n<\/pre>\n<p>Notice that we declare the Thymeleaf namespace within the HTML tag, <em>xmlns:th<\/em>=<em>&#8220;http:\/\/www.thymeleaf.org<\/em>&#8220;.<\/p>\n<p>Let\u2019s add a controller to map these views to request URIs.<\/p>\n<p><span style=\"text-decoration: underline\"><em>AppController.java<\/em><\/span><\/p>\n<pre class=\"brush:java; wrap-lines:false\">import org.springframework.stereotype.Controller;\nimport org.springframework.web.bind.annotation.GetMapping;\n\n@Controller\npublic class AppController {\n\n\t@GetMapping(\"\/\")\n\tpublic String home() {\n\t\treturn \"home\";\n\t}\n\t\n\t@GetMapping(\"\/classified\")\n\tpublic String classified() {\n\t\treturn \"classified\";\n\t}\n}\n<\/pre>\n<p>Lastly, we\u2019ll update the <code>SecurityConfiguration <\/code>class. Modify it as follows:<\/p>\n<p><span style=\"text-decoration: underline\"><em>SecurityConfiguration.java<\/em><\/span><\/p>\n<pre class=\"brush:java; highlight:[7,8,10,11]; wrap-lines:false\">@Configuration\npublic class SecurityConfiguration extends WebSecurityConfigurerAdapter {\n\n\t@Override\n\tprotected void configure(HttpSecurity http) throws Exception {\n\t\thttp.authorizeRequests()\n\t\t.antMatchers(\"\/\", \"\/actuator\").permitAll()\n\t\t.antMatchers(\"\/classified\").authenticated()\n\t\t.anyRequest().authenticated()\n\t\t.and()\n\t\t.oauth2Login();\n\t}\n}\n<\/pre>\n<p>We added <em>\u201c\/\u201d<\/em> to the <code>antMatcher <\/code>that permits anyone access. We also explicitly protect &#8220;<em>\/classified<\/em>&#8221; to authenticated users only. Finally, we added the <code>Oauth2LoginConfigurer <\/code>with <em>oauth2Login()<\/em>.<\/p>\n<p>Restart the application and point your browser to <em>http:\/\/localhost:8080\/classified<\/em>. The client application redirects you to the GitHub client login page. <\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"328\" height=\"633\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/github-oauth-login-wm.jpg\" alt=\"\" class=\"wp-image-97690\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/github-oauth-login-wm.jpg 328w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/github-oauth-login-wm-155x300.jpg 155w\" sizes=\"(max-width: 328px) 100vw, 328px\" \/><figcaption>GitHub OAuth Login<\/figcaption><\/figure>\n<\/div>\n<p>Enter your credentials. You will be asked to give the client application read-only access to your profile data. &nbsp;<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"561\" height=\"675\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/auth-user-github-wm.jpg\" alt=\"\" class=\"wp-image-97692\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/auth-user-github-wm.jpg 561w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/auth-user-github-wm-249x300.jpg 249w\" sizes=\"(max-width: 561px) 100vw, 561px\" \/><figcaption>GitHub Authorization Page<\/figcaption><\/figure>\n<\/div>\n<p>Authorize and you will be redirected to <em>http:\/\/localhost:8080\/classified<\/em>.<\/p>\n<p>In this example, GitHub acts as both the authentication server and the resource server. (The user data is the resource.) You can use the Developer Tools in Chrome, Firefox, or Edge to view how the request gets redirected between the client application and GitHub. (Use the Network tab for this task.)<\/p>\n<p>A diagram and detailed explanation of the Authorization Code Grant is available at the IETF tools web site here: <a href=\"https:\/\/tools.ietf.org\/html\/rfc6749#section-4\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/tools.ietf.org\/html\/rfc6749#section-4<\/a><\/p>\n<h3 class=\"wp-block-heading\" id=\"h-2-5-add-a-second-authentication-provider\">2.5 Add a Second Authentication Provider<\/h3>\n<p>Let\u2019s give the user an option to sign in through Google. First, you\u2019ll need to create a project in the Google API Console. Instructions are provided here <a rel=\"noreferrer noopener\" href=\"https:\/\/developers.google.com\/identity\/protocols\/oauth2\/openid-connect#appsetup\" target=\"_blank\">https:\/\/developers.google.com\/identity\/protocols\/oauth2\/openid-connect#appsetup<\/a>. Don\u2019t forget to copy the client id and client secret. Add the Google registration details in <em>application.properties<\/em>.<\/p>\n<p><span style=\"text-decoration: underline\"><em>application.properties<\/em><\/span><\/p>\n<pre class=\"brush:plain; wrap-lines:false\">spring.security.oauth2.client.registration.github.client-id=&lt;your-client-id&gt;\nspring.security.oauth2.client.registration.google.client-secret=&lt;your-client-secret&gt;\n<\/pre>\n<p>Restart the application and open a private browser window. (This is the simplest way to clear cached cookies and HTTP basic credentials.) Navigate to <em>http:\/\/localhost:8080\/classified<\/em>. Spring Boot will generate a login page with both options since it does not know which of the two registered authentication providers to use.<\/p>\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"585\" height=\"415\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/login-with-oauth2-wm.jpg\" alt=\"\" class=\"wp-image-97694\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/login-with-oauth2-wm.jpg 585w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/login-with-oauth2-wm-300x213.jpg 300w\" sizes=\"(max-width: 585px) 100vw, 585px\" \/><figcaption>Login with OAuth2<\/figcaption><\/figure>\n<p>Click on the Google link. You will be redirected to the Google OAuth2 login page. Notice that the page is asking for consent to share your:<\/p>\n<ul class=\"wp-block-list\">\n<li>name<\/li>\n<li>email address<\/li>\n<li>language preference<\/li>\n<li>profile picture<\/li>\n<\/ul>\n<p>Enter your credentials and you will be redirected to <em>http:\/\/localhost:8080\/classified\/classified<\/em>.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-2-6-add-personalization\">2.6 Add Personalization<\/h3>\n<p>Let\u2019s add a touch of personalization by displaying the user\u2019s name on the protected page. We cannot retrieve the name from the <code>Principal <\/code>object by calling its <code>getName <\/code>method, since that will return the user\u2019s id and not the name. We can, however, retrieve it with the <code>OAuth2User::getAttribute<\/code> method and add it to the model. We\u2019ll also add the user\u2019s authorities to the model to display, Add the following code to the controller class&#8217; <code>classified <\/code>method:<\/p>\n<p><span style=\"text-decoration: underline\"><em>AppController.java<\/em><\/span><\/p>\n<pre class=\"brush:java; highlight:[2,3,4]; wrap-lines:false\">\t@GetMapping(\"\/classified\")\n\tpublic String classified(@AuthenticationPrincipal OAuth2User principal, Model model) {\n\t\tmodel.addAttribute(\"name\", principal.getAttribute(\"name\"));\n\t\tmodel.addAttribute(\"authorities\", principal.getAuthorities());\n\t\treturn \"classified\";\n\t}\n<\/pre>\n<p>@AuthenticationPrincipal is used to resolve <code>Authentication::getPrincipal()<\/code> to a method argument. &nbsp;OAuth2User represents a user <code>Principal<\/code> that is registered with an OAuth 2.0 provider. <code>principal.getAuthorities() <\/code>returns a <code>Collection <\/code>of <code>GrantedAuthority<\/code>s associated with the OAuth 2.0 token<\/p>\n<p>We\u2019ll also add a check on the restricted page to display the name only if the user is authenticated. While there are different ways to accomplish this, let\u2019s make use of Thymeleaf\u2019s Spring Security integration module. Update the <em>pom.xml<\/em> file by adding the following dependency:<\/p>\n<p><span style=\"text-decoration: underline\"><em>pom.xml<\/em><\/span><\/p>\n<pre class=\"brush:xml; wrap-lines:false\">&lt;dependency&gt;\n\t&lt;groupId&gt;org.thymeleaf.extras&lt;\/groupId&gt;\n\t&lt;artifactId&gt;thymeleaf-extras-springsecurity5&lt;\/artifactId&gt;\n&lt;\/dependency&gt;\n<\/pre>\n<p>Now we can update c<em>lassified.html<\/em>. Add follows just below the <code>&lt;h2&gt;<\/code> heading:<\/p>\n<p><span style=\"text-decoration: underline\"><em>classified.html<\/em><\/span><\/p>\n<pre class=\"brush:xml; wrap-lines:false\"> \n&lt;div th:if=\"${#authorization.expression('isAuthenticated()')}\"&gt;\n    &lt;h3 th:inline=\"text\"&gt;Welcome &lt;span th:text=\"${name}\"&gt;John Doe&lt;\/span&gt;!&lt;\/h3&gt;\n    &lt;h3 th:inline=\"text\"&gt;You have the following roles and scopes: &lt;span th:text=\"${authorities}\"&gt;[ROLE_USER, SCOPE_read:user]&lt;\/span&gt;&lt;\/h3&gt;\n&lt;\/div&gt;\n   \n&lt;div th:if=\"${#authorization.expression('hasRole(''ROLE_ADMIN'')')}\"&gt;\n   &lt;h3&gt; You are assigned the role of 'ADMIN'&lt;\/h3&gt;\n&lt;\/div&gt;\n\n&lt;div th:if=\"${#authorization.expression('hasRole(''ROLE_USER'')')}\"&gt;\n   &lt;h3&gt;You are assigned the role of 'USER'.&lt;\/h3&gt;\n&lt;\/div&gt;\n<\/pre>\n<p>&nbsp;<em>#authorization. expression<\/em> is a utility object with methods used to check authorization, based on expressions. If this evaluates to true, we use the inline and text attributes to display the user\u2019s name and authorities.<\/p>\n<p>Also, we will display some feedback, depending on the user\u2019s role. For more information on Thymeleaf\u2019s Spring Security integration module, click here: <a href=\"https:\/\/github.com\/thymeleaf\/thymeleaf-extras-springsecurity\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/github.com\/thymeleaf\/thymeleaf-extras-springsecurity<\/a><\/p>\n<p>Restart the application and point your browser to <em>http:\/\/localhost:8080\/classified<\/em>.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"663\" height=\"241\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/roles-and-scopes-wm.jpg\" alt=\"\" class=\"wp-image-97695\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/roles-and-scopes-wm.jpg 663w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/roles-and-scopes-wm-300x109.jpg 300w\" sizes=\"(max-width: 663px) 100vw, 663px\" \/><figcaption>Personalized Page<\/figcaption><\/figure>\n<\/div>\n<h3 class=\"wp-block-heading\" id=\"h-2-7-add-a-logout-button\">2.7 Add a Logout Button<\/h3>\n<p>Let\u2019s add a button that allows the user to logout out of the application. Update <em>classified.html<\/em> as follows. Be sure to include it within the <code>isAuthenticated()<\/code> check:<\/p>\n<p><span style=\"text-decoration: underline\"><em>classified.html<\/em><\/span><\/p>\n<pre class=\"brush:xml; highlight:[4,5,6]; wrap-lines:false\">    &lt;div th:if=\"${#authorization.expression('isAuthenticated()')}\"&gt;\n        &lt;h3 th:inline=\"text\"&gt;Welcome &lt;span th:text=\"${name}\"&gt;John Doe&lt;\/span&gt;!&lt;\/h3&gt;\n\t&lt;h3 th:inline=\"text\"&gt;You have the following roles and scopes: &lt;span th:text=\"${authorities}\"&gt;[ROLE_USER, SCOPE_read:user]&lt;\/span&gt;&lt;\/h3&gt;\n\t&lt;form th:action=\"@{\/logout}\" method=\"post\"&gt;\n            &lt;input type=\"submit\" value=\"Sign Out\"\/&gt;\n        &lt;\/form&gt;\n    &lt;\/div&gt;\n<\/pre>\n<p>Let\u2019s also add a link to <em>\/classified<\/em> on the Home page:<\/p>\n<p><span style=\"text-decoration: underline\"><em>home.html<\/em><\/span><\/p>\n<pre class=\"brush:xml; wrap-lines:false\">&lt;p&gt;Click &lt;a th:href=\"@{\/classified}\"&gt;here&lt;\/a&gt; to see a classified page, if you dare!&lt;\/p&gt;\n<\/pre>\n<p>Restart the application and test the logout button.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"646\" height=\"240\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/logout-button-wm.jpg\" alt=\"\" class=\"wp-image-97697\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/logout-button-wm.jpg 646w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/logout-button-wm-300x111.jpg 300w\" sizes=\"(max-width: 646px) 100vw, 646px\" \/><figcaption>Logout Button<\/figcaption><\/figure>\n<\/div>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"491\" height=\"237\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/u-have-been-signed-out-wm.jpg\" alt=\"\" class=\"wp-image-97698\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/u-have-been-signed-out-wm.jpg 491w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/u-have-been-signed-out-wm-300x145.jpg 300w\" sizes=\"(max-width: 491px) 100vw, 491px\" \/><figcaption>Signed Out<\/figcaption><\/figure>\n<\/div>\n<p>Keep in mind that when using an OAuth2 authorization provider for authentication, Spring Security\u2019s logout function merely logs you out of the client application, not the authorization provider. This may sound confusing, but it makes sense. The client application shouldn\u2019t have the ability to log you out of GitHub or Google. You can verify this by clicking on the GitHub link. You will notice that you will not go through the authorization code grant flow again.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-3-summary\">3. Summary<\/h2>\n<p>in this tutorial, we showed how to integrate OAuth2 authentication and authorization with a Spring Boot application. We discussed some OAuth2 concepts and explained how they work within the Spring Security model.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-4-download-the-source-code\">4. Download the Source Code<\/h2>\n<p>This was a Spring Boot OAuth2 Tutorial.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here:<br \/>\n<a href=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/springboot-oauth2.zip\"><strong>Spring Boot OAuth2 Tutorial<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, we will show how to integrate OAuth2 with Spring Security in a Spring Boot application. 1. Introduction Many web applications use some mechanism for identifying a user, if for nothing more than to provide a personalized experience. Also, an authorization check may be required to determine if the user has the necessary &hellip;<\/p>\n","protected":false},"author":121,"featured_media":1248,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1390],"tags":[1724,46676,1386,1213,1675],"class_list":["post-97676","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-boot","tag-oauth2","tag-sociallogin","tag-spring-boot","tag-spring-mvc","tag-spring-tutorial"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Spring Boot and OAuth2 Tutorial - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"In this tutorial, we will show how to integrate OAuth2 with Spring Security in a Spring Boot application. 1. Introduction Many web applications use some\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/spring-boot-and-oauth2-tutorial\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Spring Boot and OAuth2 Tutorial - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, we will show how to integrate OAuth2 with Spring Security in a Spring Boot application. 1. Introduction Many web applications use some\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/spring-boot-and-oauth2-tutorial\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2020-12-04T09:00:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/spring-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Gilbert Lopez\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@gillopez_dev\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Gilbert Lopez\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"13 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/spring-boot-and-oauth2-tutorial\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/spring-boot-and-oauth2-tutorial\/\"},\"author\":{\"name\":\"Gilbert Lopez\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/6169578062b8f6f6a1f79c82aafdb9ce\"},\"headline\":\"Spring Boot and OAuth2 Tutorial\",\"datePublished\":\"2020-12-04T09:00:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/spring-boot-and-oauth2-tutorial\/\"},\"wordCount\":2075,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/spring-boot-and-oauth2-tutorial\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/spring-logo.jpg\",\"keywords\":[\"OAuth2\",\"sociallogin\",\"spring boot\",\"Spring MVC\",\"spring tutorial\"],\"articleSection\":[\"Boot\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/spring-boot-and-oauth2-tutorial\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/spring-boot-and-oauth2-tutorial\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/spring-boot-and-oauth2-tutorial\/\",\"name\":\"Spring Boot and OAuth2 Tutorial - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/spring-boot-and-oauth2-tutorial\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/spring-boot-and-oauth2-tutorial\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/spring-logo.jpg\",\"datePublished\":\"2020-12-04T09:00:00+00:00\",\"description\":\"In this tutorial, we will show how to integrate OAuth2 with Spring Security in a Spring Boot application. 1. Introduction Many web applications use some\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/spring-boot-and-oauth2-tutorial\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/spring-boot-and-oauth2-tutorial\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/spring-boot-and-oauth2-tutorial\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/spring-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/spring-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/spring-boot-and-oauth2-tutorial\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java Development\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"spring\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/spring\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"Boot\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/spring\/boot\/\"},{\"@type\":\"ListItem\",\"position\":6,\"name\":\"Spring Boot and OAuth2 Tutorial\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/6169578062b8f6f6a1f79c82aafdb9ce\",\"name\":\"Gilbert Lopez\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Gilbert-Lopez_avatar_1492457226-96x96.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Gilbert-Lopez_avatar_1492457226-96x96.jpg\",\"caption\":\"Gilbert Lopez\"},\"description\":\"Gilbert Lopez is an application developer and systems integration developer with experience building business solutions for large and medium-sized companies. He has worked on many Java EE projects. His roles have included lead developer, systems analyst, business analyst and consultant. Gilbert graduated from California State University in Los Angeles with a Bachelor of Science degree in Business.\",\"sameAs\":[\"https:\/\/www.javacodegeeks.com\",\"https:\/\/www.linkedin.com\/in\/gilbertlopezdeveloper\",\"https:\/\/x.com\/gillopez_dev\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/gilbert-lopez\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Spring Boot and OAuth2 Tutorial - Java Code Geeks","description":"In this tutorial, we will show how to integrate OAuth2 with Spring Security in a Spring Boot application. 1. Introduction Many web applications use some","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:\/\/examples.javacodegeeks.com\/spring-boot-and-oauth2-tutorial\/","og_locale":"en_US","og_type":"article","og_title":"Spring Boot and OAuth2 Tutorial - Java Code Geeks","og_description":"In this tutorial, we will show how to integrate OAuth2 with Spring Security in a Spring Boot application. 1. Introduction Many web applications use some","og_url":"https:\/\/examples.javacodegeeks.com\/spring-boot-and-oauth2-tutorial\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2020-12-04T09:00:00+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/spring-logo.jpg","type":"image\/jpeg"}],"author":"Gilbert Lopez","twitter_card":"summary_large_image","twitter_creator":"@gillopez_dev","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Gilbert Lopez","Est. reading time":"13 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/spring-boot-and-oauth2-tutorial\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/spring-boot-and-oauth2-tutorial\/"},"author":{"name":"Gilbert Lopez","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/6169578062b8f6f6a1f79c82aafdb9ce"},"headline":"Spring Boot and OAuth2 Tutorial","datePublished":"2020-12-04T09:00:00+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/spring-boot-and-oauth2-tutorial\/"},"wordCount":2075,"commentCount":1,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/spring-boot-and-oauth2-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/spring-logo.jpg","keywords":["OAuth2","sociallogin","spring boot","Spring MVC","spring tutorial"],"articleSection":["Boot"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/spring-boot-and-oauth2-tutorial\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/spring-boot-and-oauth2-tutorial\/","url":"https:\/\/examples.javacodegeeks.com\/spring-boot-and-oauth2-tutorial\/","name":"Spring Boot and OAuth2 Tutorial - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/spring-boot-and-oauth2-tutorial\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/spring-boot-and-oauth2-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/spring-logo.jpg","datePublished":"2020-12-04T09:00:00+00:00","description":"In this tutorial, we will show how to integrate OAuth2 with Spring Security in a Spring Boot application. 1. Introduction Many web applications use some","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/spring-boot-and-oauth2-tutorial\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/spring-boot-and-oauth2-tutorial\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/spring-boot-and-oauth2-tutorial\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/spring-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/spring-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/spring-boot-and-oauth2-tutorial\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java Development","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/"},{"@type":"ListItem","position":4,"name":"spring","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/spring\/"},{"@type":"ListItem","position":5,"name":"Boot","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/spring\/boot\/"},{"@type":"ListItem","position":6,"name":"Spring Boot and OAuth2 Tutorial"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/6169578062b8f6f6a1f79c82aafdb9ce","name":"Gilbert Lopez","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Gilbert-Lopez_avatar_1492457226-96x96.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/Gilbert-Lopez_avatar_1492457226-96x96.jpg","caption":"Gilbert Lopez"},"description":"Gilbert Lopez is an application developer and systems integration developer with experience building business solutions for large and medium-sized companies. He has worked on many Java EE projects. His roles have included lead developer, systems analyst, business analyst and consultant. Gilbert graduated from California State University in Los Angeles with a Bachelor of Science degree in Business.","sameAs":["https:\/\/www.javacodegeeks.com","https:\/\/www.linkedin.com\/in\/gilbertlopezdeveloper","https:\/\/x.com\/gillopez_dev"],"url":"https:\/\/examples.javacodegeeks.com\/author\/gilbert-lopez\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/97676","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/121"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=97676"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/97676\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/1248"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=97676"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=97676"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=97676"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}