You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2024/09/19 16:10:12 UTC

(sling-samples) 02/15: feat: working on end-to-end flow

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-samples.git

commit da759fbe6c80ea7364520b1e886b084efb0bc7b3
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Mon Sep 9 18:46:00 2024 +0200

    feat: working on end-to-end flow
---
 oauth/core/pom.xml                                 |  47 +++++++--
 .../org/apache/sling/samples/oauth_demo/Error.java |   9 ++
 .../sling/samples/oauth_demo/ErrorDetail.java      |   7 ++
 .../org/apache/sling/samples/oauth_demo/Id.java    |   6 ++
 .../org/apache/sling/samples/oauth_demo/Item.java  |   8 ++
 .../apache/sling/samples/oauth_demo/PageInfo.java  |   6 ++
 .../apache/sling/samples/oauth_demo/Snippet.java   |  12 +++
 .../apache/sling/samples/oauth_demo/Thumbnail.java |   7 ++
 .../sling/samples/oauth_demo/Thumbnails.java       |   9 ++
 .../samples/oauth_demo/YoutubeSearchResponse.java  |  13 +++
 .../samples/oauth_demo/YoutubeVideosModel.java     |  32 ++++++
 .../samples/oauth_demo/impl/YoutubeHttpClient.java |  53 ++++++++++
 .../oauth_demo/impl/YoutubeSearchServlet.java      | 107 +++++++++++++++++++++
 .../sling/samples/oauth_demo/package-info.java     |  18 ++++
 oauth/launcher/src/main/features/launcher.json     |   6 +-
 oauth/pom.xml                                      |   4 +-
 .../oauth-demo/components}/.content.xml            |   6 +-
 .../oauth-demo/components/welcome}/.content.xml    |   6 +-
 .../apps/oauth-demo/components/welcome/output.css  |   1 +
 .../oauth-demo/components/welcome/welcome.html     |  13 +++
 .../components/youtube-videos}/.content.xml        |   6 +-
 .../oauth-demo/components/youtube-videos/show.html |  12 +++
 .../jcr_root/content/oauth-demo/.content.xml       |   4 +-
 .../content/oauth-demo/{ => videos}/.content.xml   |   4 +-
 24 files changed, 368 insertions(+), 28 deletions(-)

diff --git a/oauth/core/pom.xml b/oauth/core/pom.xml
index d7dc281..1feabe1 100644
--- a/oauth/core/pom.xml
+++ b/oauth/core/pom.xml
@@ -53,7 +53,7 @@
                 <configuration>
                     <instructions>
                         <Embed-Dependency>*;scope=compile;inline=true</Embed-Dependency>
-                        <Sling-Model-Packages>org.apache.sling.samples.oauth.model</Sling-Model-Packages>
+                        <Sling-Model-Packages>org.apache.sling.samples.oauth_demo</Sling-Model-Packages>
                         <_dsannotations>*</_dsannotations>
                         <_metatypeannotations>*</_metatypeannotations>
                         <_removeheaders>
@@ -68,8 +68,8 @@
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-compiler-plugin</artifactId>
                 <configuration>
-                    <source>11</source>
-                    <target>11</target>
+                    <source>21</source>
+                    <target>21</target>
                 </configuration>
             </plugin>
             <plugin>
@@ -125,6 +125,13 @@
             <groupId>org.apache.jackrabbit</groupId>
             <artifactId>jackrabbit-api</artifactId>
         </dependency>
+        
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.servlets.annotations</artifactId>
+            <version>1.2.4</version>
+            <scope>provided</scope>
+        </dependency>
 
         <dependency>
             <groupId>org.slf4j</groupId>
@@ -140,11 +147,33 @@
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
         </dependency>
+        
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.extensions.oidc-rp</artifactId>
+            <version>0.1-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+        
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-core</artifactId>
+            <version>2.13.0</version>
+            <scope>provided</scope>
+        </dependency>
+    
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-annotations</artifactId>
+            <version>2.13.0</version>
+            <scope>provided</scope>
+        </dependency>
+    
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-databind</artifactId>
+            <version>2.13.0</version>
+            <scope>provided</scope>
+        </dependency>        
     </dependencies>
-
-    <!--
-        Attention: the autoInstallBundle was removed as deploying bundles directly and through a package is causing
-                   issues with updates and can prevent the latest code of a bundle being deployed.
-                   If you know what you are doing then you can use maven-sling-plugin directly from the Maven CLI.
-    -->
 </project>
diff --git a/oauth/core/src/main/java/org/apache/sling/samples/oauth_demo/Error.java b/oauth/core/src/main/java/org/apache/sling/samples/oauth_demo/Error.java
new file mode 100644
index 0000000..3e3cec3
--- /dev/null
+++ b/oauth/core/src/main/java/org/apache/sling/samples/oauth_demo/Error.java
@@ -0,0 +1,9 @@
+package org.apache.sling.samples.oauth_demo;
+
+import java.util.List;
+
+public record Error (
+    int code,
+    String message,
+    List<ErrorDetail> errors
+) {}
\ No newline at end of file
diff --git a/oauth/core/src/main/java/org/apache/sling/samples/oauth_demo/ErrorDetail.java b/oauth/core/src/main/java/org/apache/sling/samples/oauth_demo/ErrorDetail.java
new file mode 100644
index 0000000..7cb0bc7
--- /dev/null
+++ b/oauth/core/src/main/java/org/apache/sling/samples/oauth_demo/ErrorDetail.java
@@ -0,0 +1,7 @@
+package org.apache.sling.samples.oauth_demo;
+
+public record ErrorDetail (
+    String message,
+    String domain,
+    String reason
+) {}
\ No newline at end of file
diff --git a/oauth/core/src/main/java/org/apache/sling/samples/oauth_demo/Id.java b/oauth/core/src/main/java/org/apache/sling/samples/oauth_demo/Id.java
new file mode 100644
index 0000000..35d4c4e
--- /dev/null
+++ b/oauth/core/src/main/java/org/apache/sling/samples/oauth_demo/Id.java
@@ -0,0 +1,6 @@
+package org.apache.sling.samples.oauth_demo;
+
+public record Id (
+    String kind,
+    String videoId
+) {}
\ No newline at end of file
diff --git a/oauth/core/src/main/java/org/apache/sling/samples/oauth_demo/Item.java b/oauth/core/src/main/java/org/apache/sling/samples/oauth_demo/Item.java
new file mode 100644
index 0000000..1d6ca47
--- /dev/null
+++ b/oauth/core/src/main/java/org/apache/sling/samples/oauth_demo/Item.java
@@ -0,0 +1,8 @@
+package org.apache.sling.samples.oauth_demo;
+
+public record Item (
+    String kind,
+    String etag,
+    Id id,
+    Snippet snippet
+) {}
\ No newline at end of file
diff --git a/oauth/core/src/main/java/org/apache/sling/samples/oauth_demo/PageInfo.java b/oauth/core/src/main/java/org/apache/sling/samples/oauth_demo/PageInfo.java
new file mode 100644
index 0000000..88a550f
--- /dev/null
+++ b/oauth/core/src/main/java/org/apache/sling/samples/oauth_demo/PageInfo.java
@@ -0,0 +1,6 @@
+package org.apache.sling.samples.oauth_demo;
+
+public record PageInfo (
+    int totalResults,
+    int resultsPerPage
+) {}
\ No newline at end of file
diff --git a/oauth/core/src/main/java/org/apache/sling/samples/oauth_demo/Snippet.java b/oauth/core/src/main/java/org/apache/sling/samples/oauth_demo/Snippet.java
new file mode 100644
index 0000000..18f11ae
--- /dev/null
+++ b/oauth/core/src/main/java/org/apache/sling/samples/oauth_demo/Snippet.java
@@ -0,0 +1,12 @@
+package org.apache.sling.samples.oauth_demo;
+
+public record Snippet (
+    String publishedAt,
+    String channelId,
+    String title,
+    String description,
+    Thumbnails thumbnails,
+    String channelTitle,
+    String liveBroadcastContent,
+    String publishTime
+) {}
\ No newline at end of file
diff --git a/oauth/core/src/main/java/org/apache/sling/samples/oauth_demo/Thumbnail.java b/oauth/core/src/main/java/org/apache/sling/samples/oauth_demo/Thumbnail.java
new file mode 100644
index 0000000..8a5ae8a
--- /dev/null
+++ b/oauth/core/src/main/java/org/apache/sling/samples/oauth_demo/Thumbnail.java
@@ -0,0 +1,7 @@
+package org.apache.sling.samples.oauth_demo;
+
+public record Thumbnail (
+    String url,
+    int width,
+    int height
+) {}
\ No newline at end of file
diff --git a/oauth/core/src/main/java/org/apache/sling/samples/oauth_demo/Thumbnails.java b/oauth/core/src/main/java/org/apache/sling/samples/oauth_demo/Thumbnails.java
new file mode 100644
index 0000000..226c884
--- /dev/null
+++ b/oauth/core/src/main/java/org/apache/sling/samples/oauth_demo/Thumbnails.java
@@ -0,0 +1,9 @@
+package org.apache.sling.samples.oauth_demo;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public record Thumbnails (
+    @JsonProperty("default") Thumbnail defaultThumbnail,
+    Thumbnail medium,
+    Thumbnail high
+) {}
\ No newline at end of file
diff --git a/oauth/core/src/main/java/org/apache/sling/samples/oauth_demo/YoutubeSearchResponse.java b/oauth/core/src/main/java/org/apache/sling/samples/oauth_demo/YoutubeSearchResponse.java
new file mode 100644
index 0000000..88fabb2
--- /dev/null
+++ b/oauth/core/src/main/java/org/apache/sling/samples/oauth_demo/YoutubeSearchResponse.java
@@ -0,0 +1,13 @@
+package org.apache.sling.samples.oauth_demo;
+
+import java.util.List;
+
+public record YoutubeSearchResponse (
+    String kind,
+    String etag,
+    String nextPageToken,
+    String regionCode,
+    PageInfo pageInfo,
+    List<Item> items,
+    Error error            
+) {}
\ No newline at end of file
diff --git a/oauth/core/src/main/java/org/apache/sling/samples/oauth_demo/YoutubeVideosModel.java b/oauth/core/src/main/java/org/apache/sling/samples/oauth_demo/YoutubeVideosModel.java
new file mode 100644
index 0000000..f4178ac
--- /dev/null
+++ b/oauth/core/src/main/java/org/apache/sling/samples/oauth_demo/YoutubeVideosModel.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.samples.oauth_demo;
+
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.models.annotations.Model;
+import org.apache.sling.models.annotations.injectorspecific.SlingObject;
+
+@Model(adaptables = SlingHttpServletRequest.class)
+public class YoutubeVideosModel {
+
+    @SlingObject
+    private SlingHttpServletRequest request;
+
+    public YoutubeSearchResponse getResponse() {
+        return (YoutubeSearchResponse) request.getAttribute("ytResponse");
+    }
+}
diff --git a/oauth/core/src/main/java/org/apache/sling/samples/oauth_demo/impl/YoutubeHttpClient.java b/oauth/core/src/main/java/org/apache/sling/samples/oauth_demo/impl/YoutubeHttpClient.java
new file mode 100644
index 0000000..43e2789
--- /dev/null
+++ b/oauth/core/src/main/java/org/apache/sling/samples/oauth_demo/impl/YoutubeHttpClient.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.samples.oauth_demo.impl;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.http.HttpClient;
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
+import java.net.http.HttpResponse.BodyHandlers;
+
+import org.apache.sling.samples.oauth_demo.YoutubeSearchResponse;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class YoutubeHttpClient {
+    
+    public static final String API_BASE = "https://youtube.googleapis.com/youtube/v3";
+    
+    public YoutubeSearchResponse searchVideos(String query, String accessToken) throws IOException, InterruptedException {
+        
+        try ( HttpClient client = HttpClient.newHttpClient() ) {
+            HttpRequest searchRequest = HttpRequest.newBuilder()
+                .uri(URI.create(API_BASE + "/search?part=snippet&maxResults=20&q=" + query + "&type=video"))
+                .header("Authorization", "Bearer " + accessToken)
+                .header("Accept", "application/json")
+                .build();
+            
+            HttpResponse<String> response = client.send(searchRequest, BodyHandlers.ofString());
+    
+            String body = response.body();
+            
+            System.out.println(body);
+            
+            ObjectMapper mapper = new ObjectMapper();
+            return mapper.reader().readValue(body, YoutubeSearchResponse.class);
+        }
+    }        
+}
\ No newline at end of file
diff --git a/oauth/core/src/main/java/org/apache/sling/samples/oauth_demo/impl/YoutubeSearchServlet.java b/oauth/core/src/main/java/org/apache/sling/samples/oauth_demo/impl/YoutubeSearchServlet.java
new file mode 100644
index 0000000..5aa6d2d
--- /dev/null
+++ b/oauth/core/src/main/java/org/apache/sling/samples/oauth_demo/impl/YoutubeSearchServlet.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.samples.oauth_demo.impl;
+
+import java.io.IOException;
+
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.SlingHttpServletResponse;
+import org.apache.sling.api.request.RequestDispatcherOptions;
+import org.apache.sling.extensions.oidc_rp.OidcClient;
+import org.apache.sling.extensions.oidc_rp.OidcConnection;
+import org.apache.sling.extensions.oidc_rp.OidcToken;
+import org.apache.sling.extensions.oidc_rp.OidcTokenStore;
+import org.apache.sling.extensions.oidc_rp.support.OAuthEnabledSlingServlet;
+import org.apache.sling.samples.oauth_demo.YoutubeSearchResponse;
+import org.apache.sling.servlets.annotations.SlingServletResourceTypes;
+import org.jetbrains.annotations.NotNull;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
+
+@Component(service = { Servlet.class })
+@SlingServletResourceTypes(resourceTypes = "oauth-demo/components/youtube-videos", methods = "GET", extensions = "html")
+public class YoutubeSearchServlet extends OAuthEnabledSlingServlet {
+
+    private static final long serialVersionUID = 1L;
+    private final OidcConnection connection;
+    private OidcTokenStore tokenStore;
+    private OidcClient oidcClient;
+    
+    @Activate
+    public YoutubeSearchServlet(@Reference OidcConnection connection, @Reference OidcTokenStore tokenStore, @Reference OidcClient oidcClient) {
+        this.connection = connection;
+        this.tokenStore = tokenStore;
+        this.oidcClient = oidcClient;
+    }
+
+    @Override
+    protected @NotNull String getRedirectPath(@NotNull SlingHttpServletRequest request) {
+        return request.getRequestURI();
+    }
+
+    @Override
+    protected @NotNull OidcConnection getConnection() {
+        return connection;
+    }
+    
+    @Override
+    protected @NotNull OidcClient getOidcClient() {
+        return oidcClient;
+    }
+    
+    @Override
+    protected @NotNull OidcTokenStore getTokenStore() {
+        return tokenStore;
+    }
+
+    @Override
+    protected void doGetWithToken(@NotNull SlingHttpServletRequest request, @NotNull SlingHttpServletResponse response,
+            OidcToken token) throws IOException, ServletException {
+
+        try {
+            YoutubeHttpClient client = new YoutubeHttpClient();
+            YoutubeSearchResponse youtubeResponse = client.searchVideos("adaptTo", token.getValue());
+            
+            RequestDispatcherOptions opts = new RequestDispatcherOptions();
+            opts.setReplaceSelectors("show");
+            
+            request.setAttribute("ytResponse", youtubeResponse);
+            response.setContentType("text/html");
+            request.getRequestDispatcher(request.getResource(), opts).include(request, response);
+            
+            // TODO - needs a thin use object shim to expose the request attribute or a generic BVP
+            
+//            response.setStatus(HttpServletResponse.SC_OK);
+//            response.setContentType("text/html");
+//            response.getWriter().write(String.format("<p>Got %s results out of total %s</p>", youtubeResponse.items().size(), youtubeResponse.pageInfo().totalResults()));
+//            response.getWriter().write("<ul>");
+//            for (Item item : youtubeResponse.items()) {
+//                response.getWriter().write(String.format("<li><a href=\"https://www.youtube.com/watch?v=%s\">%s</a></li>",
+//                        item.id().videoId(), item.snippet().title()));
+//            }
+//            response.getWriter().write("</ul>");
+        } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
+            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Please retry later");
+        }
+    }
+}
diff --git a/oauth/core/src/main/java/org/apache/sling/samples/oauth_demo/package-info.java b/oauth/core/src/main/java/org/apache/sling/samples/oauth_demo/package-info.java
new file mode 100644
index 0000000..1174b9b
--- /dev/null
+++ b/oauth/core/src/main/java/org/apache/sling/samples/oauth_demo/package-info.java
@@ -0,0 +1,18 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+@org.osgi.annotation.versioning.Version("1.0.0")
+package org.apache.sling.samples.oauth_demo;
\ No newline at end of file
diff --git a/oauth/launcher/src/main/features/launcher.json b/oauth/launcher/src/main/features/launcher.json
index 430812b..0334e9a 100644
--- a/oauth/launcher/src/main/features/launcher.json
+++ b/oauth/launcher/src/main/features/launcher.json
@@ -2,7 +2,11 @@
   "bundles": [
     {
         "id": "org.apache.sling.samples/org.apache.sling.samples.oauth.core/1.0-SNAPSHOT",
-        "start-order": 20
+        "start-order": 25
+    },
+    {
+        "id": "org.apache.sling/org.apache.sling.extensions.oidc-rp/0.1-SNAPSHOT",
+        "start-order": 24
     }
   ],
   "content-packages:ARTIFACTS|required": [
diff --git a/oauth/pom.xml b/oauth/pom.xml
index 28196dd..3698d86 100644
--- a/oauth/pom.xml
+++ b/oauth/pom.xml
@@ -840,14 +840,14 @@
           
           
           
-          <source>11</source>
+          <source>21</source>
                                                                                 
           
           
           
           
           
-          <target>11</target>
+          <target>21</target>
                                                                                 
           
           
diff --git a/oauth/ui.apps/src/main/content/jcr_root/content/oauth-demo/.content.xml b/oauth/ui.apps/src/main/content/jcr_root/apps/oauth-demo/components/.content.xml
similarity index 82%
copy from oauth/ui.apps/src/main/content/jcr_root/content/oauth-demo/.content.xml
copy to oauth/ui.apps/src/main/content/jcr_root/apps/oauth-demo/components/.content.xml
index 2d247a2..20e138a 100644
--- a/oauth/ui.apps/src/main/content/jcr_root/content/oauth-demo/.content.xml
+++ b/oauth/ui.apps/src/main/content/jcr_root/apps/oauth-demo/components/.content.xml
@@ -17,8 +17,6 @@
     specific language governing permissions and limitations
     under the License.
 -->
-<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
+<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
           jcr:primaryType="sling:Folder"
-          jcr:title="Sling OAuth Demo"
-          jcr:description="Sling OAuth Demo Content Root"
-/>
\ No newline at end of file
+/>
diff --git a/oauth/ui.apps/src/main/content/jcr_root/content/oauth-demo/.content.xml b/oauth/ui.apps/src/main/content/jcr_root/apps/oauth-demo/components/welcome/.content.xml
similarity index 82%
copy from oauth/ui.apps/src/main/content/jcr_root/content/oauth-demo/.content.xml
copy to oauth/ui.apps/src/main/content/jcr_root/apps/oauth-demo/components/welcome/.content.xml
index 2d247a2..20e138a 100644
--- a/oauth/ui.apps/src/main/content/jcr_root/content/oauth-demo/.content.xml
+++ b/oauth/ui.apps/src/main/content/jcr_root/apps/oauth-demo/components/welcome/.content.xml
@@ -17,8 +17,6 @@
     specific language governing permissions and limitations
     under the License.
 -->
-<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
+<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
           jcr:primaryType="sling:Folder"
-          jcr:title="Sling OAuth Demo"
-          jcr:description="Sling OAuth Demo Content Root"
-/>
\ No newline at end of file
+/>
diff --git a/oauth/ui.apps/src/main/content/jcr_root/apps/oauth-demo/components/welcome/output.css b/oauth/ui.apps/src/main/content/jcr_root/apps/oauth-demo/components/welcome/output.css
new file mode 100644
index 0000000..c12b6dd
--- /dev/null
+++ b/oauth/ui.apps/src/main/content/jcr_root/apps/oauth-demo/components/welcome/output.css
@@ -0,0 +1 @@
+/*! tailwindcss v3.4.10 | MIT License | https://tailwindcss.com*/*,:after,:before{border:0 solid #e5e7eb;box-sizing:border-box}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-tap-highlight-color:transparent}body{line-height:inheri [...]
\ No newline at end of file
diff --git a/oauth/ui.apps/src/main/content/jcr_root/apps/oauth-demo/components/welcome/welcome.html b/oauth/ui.apps/src/main/content/jcr_root/apps/oauth-demo/components/welcome/welcome.html
new file mode 100644
index 0000000..7882f74
--- /dev/null
+++ b/oauth/ui.apps/src/main/content/jcr_root/apps/oauth-demo/components/welcome/welcome.html
@@ -0,0 +1,13 @@
+<!doctype html>
+<html>
+<head>
+  <meta charset="UTF-8">
+  <meta name="viewport" content="width=device-width, initial-scale=1.0">
+  <link href="./output.css" rel="stylesheet">
+</head>
+<body>
+<h1 class="text-3xl font-bold underline">OAuth Demo</h1>
+<p>Welcome to the Sling OAuth demo.</p>
+<p>Access the <a href="oauth-demo/videos.html">YouTube videos</a> page.</p>
+</body>
+</html>
diff --git a/oauth/ui.apps/src/main/content/jcr_root/content/oauth-demo/.content.xml b/oauth/ui.apps/src/main/content/jcr_root/apps/oauth-demo/components/youtube-videos/.content.xml
similarity index 82%
copy from oauth/ui.apps/src/main/content/jcr_root/content/oauth-demo/.content.xml
copy to oauth/ui.apps/src/main/content/jcr_root/apps/oauth-demo/components/youtube-videos/.content.xml
index 2d247a2..20e138a 100644
--- a/oauth/ui.apps/src/main/content/jcr_root/content/oauth-demo/.content.xml
+++ b/oauth/ui.apps/src/main/content/jcr_root/apps/oauth-demo/components/youtube-videos/.content.xml
@@ -17,8 +17,6 @@
     specific language governing permissions and limitations
     under the License.
 -->
-<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
+<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
           jcr:primaryType="sling:Folder"
-          jcr:title="Sling OAuth Demo"
-          jcr:description="Sling OAuth Demo Content Root"
-/>
\ No newline at end of file
+/>
diff --git a/oauth/ui.apps/src/main/content/jcr_root/apps/oauth-demo/components/youtube-videos/show.html b/oauth/ui.apps/src/main/content/jcr_root/apps/oauth-demo/components/youtube-videos/show.html
new file mode 100644
index 0000000..3da0ae5
--- /dev/null
+++ b/oauth/ui.apps/src/main/content/jcr_root/apps/oauth-demo/components/youtube-videos/show.html
@@ -0,0 +1,12 @@
+<!doctype html>
+<html>
+<head>
+  <meta charset="UTF-8">
+  <meta name="viewport" content="width=device-width, initial-scale=1.0">
+</head>
+<body data-sly-use.youtube="org.apache.sling.samples.oauth_demo.YoutubeVideosModel">
+<h1>Search results</h1>
+<p>ERROR? ${youtube.response.error.message}</p>
+<p>Got ${youtube.response.items.size} results of out total ${youtube.response.pageInfo.totalResults}</p>
+</body>
+</html>
\ No newline at end of file
diff --git a/oauth/ui.apps/src/main/content/jcr_root/content/oauth-demo/.content.xml b/oauth/ui.apps/src/main/content/jcr_root/content/oauth-demo/.content.xml
index 2d247a2..a731489 100644
--- a/oauth/ui.apps/src/main/content/jcr_root/content/oauth-demo/.content.xml
+++ b/oauth/ui.apps/src/main/content/jcr_root/content/oauth-demo/.content.xml
@@ -18,7 +18,7 @@
     under the License.
 -->
 <jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
+          xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
           jcr:primaryType="sling:Folder"
-          jcr:title="Sling OAuth Demo"
-          jcr:description="Sling OAuth Demo Content Root"
+          sling:resourceType="oauth-demo/components/welcome"
 />
\ No newline at end of file
diff --git a/oauth/ui.apps/src/main/content/jcr_root/content/oauth-demo/.content.xml b/oauth/ui.apps/src/main/content/jcr_root/content/oauth-demo/videos/.content.xml
similarity index 88%
copy from oauth/ui.apps/src/main/content/jcr_root/content/oauth-demo/.content.xml
copy to oauth/ui.apps/src/main/content/jcr_root/content/oauth-demo/videos/.content.xml
index 2d247a2..bfb8f19 100644
--- a/oauth/ui.apps/src/main/content/jcr_root/content/oauth-demo/.content.xml
+++ b/oauth/ui.apps/src/main/content/jcr_root/content/oauth-demo/videos/.content.xml
@@ -18,7 +18,7 @@
     under the License.
 -->
 <jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
+          xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
           jcr:primaryType="sling:Folder"
-          jcr:title="Sling OAuth Demo"
-          jcr:description="Sling OAuth Demo Content Root"
+          sling:resourceType="oauth-demo/components/youtube-videos"
 />
\ No newline at end of file