<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sourin Ghosh on Medium]]></title>
        <description><![CDATA[Stories by Sourin Ghosh on Medium]]></description>
        <link>https://medium.com/@souringhosh?source=rss-51d9e237b0fc------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*mO88ASMSuM9A32uYu5aGCw.png</url>
            <title>Stories by Sourin Ghosh on Medium</title>
            <link>https://medium.com/@souringhosh?source=rss-51d9e237b0fc------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 09:41:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@souringhosh/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Setting up Hadoop natively on Windows and running your first MapReduce job, no WSL needed]]></title>
            <link>https://medium.com/@souringhosh/setting-up-hadoop-natively-on-windows-and-running-your-first-mapreduce-job-no-wsl-needed-d744771daa6b?source=rss-51d9e237b0fc------2</link>
            <guid isPermaLink="false">https://medium.com/p/d744771daa6b</guid>
            <category><![CDATA[hadoop]]></category>
            <category><![CDATA[installing-apache-hadoop]]></category>
            <category><![CDATA[hadoop-mapreduce]]></category>
            <category><![CDATA[installing-hadoop-windows]]></category>
            <category><![CDATA[apache-hadoop]]></category>
            <dc:creator><![CDATA[Sourin Ghosh]]></dc:creator>
            <pubDate>Sat, 14 Feb 2026 08:03:37 GMT</pubDate>
            <atom:updated>2026-02-14T08:26:59.555Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hfi-hzIqnxWgWf4JqRvdbA.png" /></figure><h3>Installation and configuration (Apache Hadoop)</h3><p>JDK — We will download and install JDK 21 from the following link. <br>Since I am using Windows, I will choose the .msi file.<br><a href="https://www.oracle.com/java/technologies/downloads/#jdk21-windows">https://www.oracle.com/java/technologies/downloads/#jdk21-windows</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xp4Uy59CdZwxSkWch-gQMg.png" /></figure><h4>Start installation</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B8ECJffzryBP3u91hU7umw.png" /></figure><h4>Complete installation and verify from PowerShell</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4JVhQxvQxs3MU0QHPIJ6aw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4yoXJLRVcDprr5QuFTyOYA.png" /></figure><h4>Configuring Java, Hadoop &amp; setting environment variables</h4><p>Go to the installation location of Java, mostly C:\Program Files\Java.<br>Copy the Java folder and paste it inside a folder where no folder names are having spaces, like: <strong>C:\Users\souri\dev\Java</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j_Z-QI0blQ4GGV7GJa5uoQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_25S9xIf5LvsTmbhrwtFsQ.png" /></figure><p>Download Apache Hadoop from the following link: <a href="https://www.apache.org/dyn/closer.cgi/hadoop/common/hadoop-3.4.2/hadoop-3.4.2.tar.gz"><strong>https://www.apache.org/dyn/closer.cgi/hadoop/common/hadoop-3.4.2/hadoop-3.4.2.tar.gz</strong></a></p><p>Copy the tar file and paste inside a folder where you want to install Hadoop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CpEY-EvCdW1nONQwsPFc7g.png" /></figure><p>Now go inside the folder where you pasted the tar file and right and open PowerShell over there:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wth-x8aNvx50pLIHKmPNRA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wF6Huq1GL7SwOKnBiqkLeA.png" /></figure><p>Run the following command in the opened PowerShell:<br><strong>tar -xvzf .\hadoop-3.4.2.tar.gz</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xrb8gvJJwtFnA5A48povNw.png" /></figure><p>Once extraction is complete it should display a new folder containing all the contents in a folder with the name of the tar file, like: <strong>hadoop-3.4.2</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g7GiT_oPz2iY0Ufpe5_tBA.png" /></figure><p>Add <strong>JAVA_HOME</strong> and <strong>HADOOP_HOME</strong> to environment variables:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m6uAnE4R20OfCFDec1_JKQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*rxtBhYgdh7-4IaHA2Q-JzQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yioKDpuW-LF79lwa6wlVug.png" /></figure><p>Append <strong>JAVA_HOME\bin</strong> &amp; <strong>HADOOP_HOME\bin</strong> to Path variable:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Eh6IK0oS_EZgrw4eeqb47g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9ClkBTjJAxAtN2M3v-AgLw.png" /></figure><p>Download windows specific Hadoop bin files needed, from the following links:</p><p><a href="https://github.com/cdarlint/winutils/raw/refs/heads/master/hadoop-3.3.6/bin/winutils.exe"><strong>https://github.com/cdarlint/winutils/raw/refs/heads/master/hadoop-3.3.6/bin/winutils.exe</strong></a></p><p><a href="https://github.com/cdarlint/winutils/raw/refs/heads/master/hadoop-3.3.6/bin/hadoop.dll"><strong>https://github.com/cdarlint/winutils/raw/refs/heads/master/hadoop-3.3.6/bin/hadoop.dll</strong></a></p><p>Copy these 2 files and paste inside the <strong>bin</strong> folder of your <strong>hadoop-3.4.2</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GVStc6_niwL1q3s29mWymw.png" /></figure><p>Create a <strong>data</strong> folder inside <strong>hadoop-3.4.2</strong> folder. Create folders: <strong>namenode</strong>, <strong>datanode</strong> inside the created <strong>data</strong> folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mv8CEdImvLzw4BNLr_Y4Ww.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mUG5Wrx25RZCB57E5E_P_g.png" /></figure><p>Navigate to <strong>hadoop-3.4.2\etc\hadoop</strong> folder and open <strong>hadoop-env.cmd</strong> in Notepad or some other text editor and add the following lines:</p><pre>set JAVA_HOME=C:\Users\souri\dev\Java\jdk-21.0.10<br>set HADOOP_HOME=C:\Users\souri\dev\hadoop-3.4.2<br>set HADOOP_CONF_DIR=%HADOOP_HOME%\etc\hadoop<br>set YARN_CONF_DIR=%HADOOP_CONF_DIR%<br>set PATH=%PATH%;%HADOOP_HOME%\bin</pre><p>Save the file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MFe6bepC3rPYbpcPzMmDnw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jfFI5MeyMfCW3LL2QD335g.png" /></figure><p>Navigate to <strong>hadoop-3.4.2\etc\hadoop</strong> folder and open <strong>yarn-env.cmd</strong> in Notepad or some other text editor and add the following lines:</p><pre>set YARN_OPTS=%YARN_OPTS% - add-opens=java.base/java.lang=ALL-UNNAMED<br>set YARN_OPTS=%YARN_OPTS% - add-opens=java.base/java.lang.reflect=ALL-UNNAMED<br>set YARN_OPTS=%YARN_OPTS% - add-opens=java.base/java.io=ALL-UNNAMED<br>set YARN_OPTS=%YARN_OPTS% - add-opens=java.base/java.util=ALL-UNNAMED</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gCZ2ibDFZpY9XcOzY9UpdQ.png" /></figure><p>Save the file.</p><p>Navigate to <strong>hadoop-3.4.2\etc\hadoop</strong> folder again and open <strong>Core-site.xml</strong> and add the following lines inside the &lt;configuration&gt; tag:</p><pre>&lt;property&gt;<br>&lt;name&gt;fs.defaultFS&lt;/name&gt;<br>&lt;value&gt;hdfs://localhost:19000&lt;/value&gt;<br>&lt;/property&gt;<br>&lt;property&gt;<br>&lt;name&gt;hadoop.proxyuser.souri.hosts&lt;/name&gt;<br>&lt;value&gt;127.0.0.1,192.168.59.1&lt;/value&gt;<br>&lt;/property&gt;<br>&lt;property&gt;<br>&lt;name&gt;hadoop.proxyuser.souri.users&lt;/name&gt;<br>&lt;value&gt;souri&lt;/value&gt;<br>&lt;/property&gt;<br>&lt;property&gt;<br>&lt;name&gt;hadoop.proxyuser.souri.groups&lt;/name&gt;<br>&lt;value&gt;souri&lt;/value&gt;<br>&lt;/property&gt;</pre><p>Replace <strong>souri</strong> with your username while typing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_MbiF6rMwJkZWxc8g6Wj8Q.png" /></figure><p>Navigate to <strong>hadoop-3.4.2\etc\hadoop</strong> folder again and open <strong>mapred-site.xml</strong> and add the following lines inside the &lt;configuration&gt; tag:</p><pre>&lt;property&gt;<br>&lt;name&gt;mapreduce.framework.name&lt;/name&gt;<br>&lt;value&gt;yarn&lt;/value&gt;<br>&lt;/property&gt;<br>&lt;property&gt;<br>&lt;name&gt;mapreduce.jobtracker.address&lt;/name&gt;<br>&lt;value&gt;local&lt;/value&gt;<br>&lt;/property&gt;<br>&lt;property&gt;<br>&lt;! - total memory allocated in MB to each map job from total RAM →<br>&lt;name&gt;mapreduce.map.memory.mb&lt;/name&gt;<br>&lt;value&gt;512&lt;/value&gt;<br>&lt;/property&gt;<br>&lt;property&gt;<br>&lt;! - total memory allocated in MB to each reducer job from total RAM →<br>&lt;name&gt;mapreduce.reduce.memory.mb&lt;/name&gt;<br>&lt;value&gt;512&lt;/value&gt;<br>&lt;/property&gt;<br>&lt;property&gt;<br>&lt;! - values of this property should be less then mapreduce.map.memory.mb →<br>&lt;name&gt;mapreduce.map.java.opts&lt;/name&gt;<br>&lt;value&gt;-Xmx256m&lt;/value&gt;<br>&lt;/property&gt;<br>&lt;property&gt;<br>&lt;! - values of this property should be less then mapreduce.reduce.memory.mb →<br>&lt;name&gt;mapreduce.reduce.java.opts&lt;/name&gt;<br>&lt;value&gt;-Xmx256m&lt;/value&gt;<br>&lt;/property&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S4BacJKUIs9zK1cdcgxbug.png" /></figure><p>Navigate to <strong>hadoop-3.4.2\etc\hadoop</strong> folder again and open <strong>yarn-site.xml</strong> and add the following lines inside the &lt;configuration&gt; tag:</p><pre>&lt;property&gt;<br>&lt;name&gt;yarn.nodemanager.aux-services&lt;/name&gt;<br>&lt;value&gt;mapreduce_shuffle&lt;/value&gt;<br>&lt;/property&gt;<br>&lt;property&gt;<br>&lt;name&gt;yarn.nodemanager.aux-services.mapreduce.shuffle.class&lt;/name&gt;<br>&lt;value&gt;org.apache.hadoop.mapred.ShuffleHandler&lt;/value&gt;<br>&lt;/property&gt;<br>&lt;property&gt;<br>&lt;name&gt;yarn.nodemanager.resource.memory-mb&lt;/name&gt;<br>&lt;value&gt;10000&lt;/value&gt;<br>&lt;description&gt;Amount of physical memory, in MB, that can be allocated for containers.&lt;/description&gt;<br>&lt;/property&gt;<br>&lt;property&gt;<br>&lt;name&gt;yarn.scheduler.minimum-allocation-mb&lt;/name&gt;<br>&lt;value&gt;500&lt;/value&gt;<br>&lt;/property&gt;<br>&lt;property&gt;<br>&lt;name&gt;yarn.application.classpath&lt;/name&gt;<br>&lt;value&gt;%HADOOP_CONF_DIR%,%HADOOP_COMMON_HOME%/share/hadoop/common/*,%HADOOP_COMMON_HOME%/share/hadoop/common/lib/*,%HADOOP_HDFS_HOME%/share/hadoop/hdfs/*,%HADOOP_HDFS_HOME%/share/hadoop/hdfs/lib/*,%HADOOP_MAPRED_HOME%/share/hadoop/mapreduce/*,%HADOOP_MAPRED_HOME%/share/hadoop/mapreduce/lib/*,%HADOOP_YARN_HOME%/share/hadoop/yarn/*,%HADOOP_YARN_HOME%/share/hadoop/yarn/lib/*&lt;/value&gt;<br>&lt;/property&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9mUR1UeUbnIYeiDqaLJDfg.png" /></figure><p>Navigate to <strong>hadoop-3.4.2\etc\hadoop</strong> folder again and open <strong>hdfs-site.xml</strong> and add the following lines inside the &lt;configuration&gt; tag:</p><pre>&lt;property&gt;<br>&lt;name&gt;dfs.replication&lt;/name&gt;<br>&lt;value&gt;1&lt;/value&gt;<br>&lt;/property&gt;<br>&lt;property&gt;<br>&lt;name&gt;dfs.namenode.name.dir&lt;/name&gt;<br>&lt;value&gt;file:///C:/Users/souri/dev/hadoop-3.4.2/data/namenode&lt;/value&gt;<br>&lt;/property&gt;<br>&lt;property&gt;<br>&lt;name&gt;dfs.datanode.data.dir&lt;/name&gt;<br>&lt;value&gt;file:///C:/Users/souri/dev/hadoop-3.4.2/data/datanode&lt;/value&gt;<br>&lt;/property&gt;<br>&lt;property&gt;<br>&lt;name&gt;dfs.webhdfs.enabled&lt;/name&gt;<br>&lt;value&gt;true&lt;/value&gt;<br>&lt;description&gt;<br>Enable WebHDFS (REST API) in Namenodes and Datanodes.<br>&lt;/description&gt;<br>&lt;/property&gt;<br>&lt;property&gt;<br>&lt;name&gt;dfs.data.dir&lt;/name&gt;<br>&lt;value&gt;/app/hadoop/tmp/dfs/name/data&lt;/value&gt;<br>&lt;final&gt;true&lt;/final&gt;<br>&lt;/property&gt;<br>&lt;property&gt;<br>&lt;name&gt;dfs.name.dir&lt;/name&gt;<br>&lt;value&gt;/app/hadoop/tmp/dfs/name&lt;/value&gt;<br>&lt;final&gt;true&lt;/final&gt;<br>&lt;/property&gt;</pre><p>Replace <strong>souri</strong> with your username while typing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_MbiF6rMwJkZWxc8g6Wj8Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4kpGnjIQcVA227FBagVDGA.png" /></figure><p>Create a folder <strong>tmp</strong> inside HADOOP_HOME(<strong>C:\Users\souri\dev\hadoop-3.4.2</strong>) and give permission using the following command<br> <br><strong>winutils.exe chmod -R 777 C:\Users\souri\dev\hadoop-3.4.2\data<br>winutils.exe chmod -R 777 C:\Users\souri\dev\hadoop-3.4.2\tmp</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o4Y3_4MOE1nZX3WHQfwoCQ.png" /></figure><p>Testing the installation<br> <br>Go to the <strong>bin</strong> directory in HADOOP_HOME(C:\Users\souri\dev\hadoop-3.4.2). And then type <br><strong>hdfs namenode -format </strong><br> <br>It should output something like this and exit with 0. If it exists with 1, then there is an error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cgmNGpH0Pp7F8ThknOrfMQ.png" /></figure><p>Now go to the <strong>sbin</strong> directory in hadoop home and right click the <strong>start-dfs.cmd </strong>file and select Run As Administrator. It should open up two cmd windows, if it gives a shutdown message, then we have an error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UraV3BjCsv2L-7PgTHgZIQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zhyOKlrsKA6QbRlB7jt8Dg.png" /></figure><p>Now go to the <strong>sbin</strong> directory in hadoop home and right click the <strong>start-yarn.cmd </strong>file and select Run As Administrator. It should open up two cmd windows, if it gives a shutdown message, then we have an error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z-TqXfg623eVLMrp3zDcww.png" /></figure><blockquote><strong>Running As Administrator is only needed if you are facing permission interpretation issues in Windows for the tmp folder of hadoop. This is a temporary fix only.</strong></blockquote><p>Now once all 4 terminals are running without errors, lets open another cmd window and type jps command to check if our setup is running correctly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F8UVQ-YKXmMdyQAH9yLzew.png" /></figure><p>Now we will go to the following localhost to check if hadoop web interface is running or not: <br><a href="http://localhost:9870/"><strong>http://localhost:9870/</strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eMCWzzKzEbh5jg0IRLeinQ.png" /></figure><p>We also get another interface provided by yarn where we can check the system details.<br><a href="http://localhost:8088/"><strong>http://localhost:8088/</strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5M58qwcFARouVkuB7jBttQ.png" /></figure><p>Alright! So with that we successfully setup Hadoop on Windows natively without using WSL. 👌👍</p><h3>Running the first MapReduce job</h3><p>Create new Java project in Intellij Idea<br> Make sure you choose Maven as Build system for easier dependency management of Hadoop libraries and easier process of jar generation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XtN0OXppA2U3zfIeXRYKaQ.png" /></figure><p>Once project is created add the following dependencies in the pom.xml</p><pre>&lt;dependencies&gt;<br>&lt;dependency&gt;<br>&lt;groupId&gt;org.apache.hadoop&lt;/groupId&gt;<br>&lt;artifactId&gt;hadoop-client&lt;/artifactId&gt;<br>&lt;version&gt;3.4.2&lt;/version&gt;<br>&lt;/dependency&gt;<br>&lt;dependency&gt;<br>&lt;groupId&gt;org.apache.hadoop&lt;/groupId&gt;<br>&lt;artifactId&gt;hadoop-common&lt;/artifactId&gt;<br>&lt;version&gt;3.4.2&lt;/version&gt;<br>&lt;/dependency&gt;<br>&lt;dependency&gt;<br>&lt;groupId&gt;org.apache.hadoop&lt;/groupId&gt;<br>&lt;artifactId&gt;hadoop-mapreduce-client-core&lt;/artifactId&gt;<br>&lt;version&gt;3.4.2&lt;/version&gt;<br>&lt;/dependency&gt;<br>&lt;/dependencies&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HnNA_IWrVvvuHSKRnHe1wg.png" /></figure><p>Right Click on java folder inside <strong>src/main/java</strong> and create a package named <strong>org.example.hadoop.wordcount</strong>, right click on this new package and create a new Java class named <strong>WordCount</strong> and paste the WordCount code from Hadoop Tutorial (<a href="https://hadoop.apache.org/docs/stable/hadoop-mapreduce-client/hadoop-mapreduce-client-core/MapReduceTutorial.html#Example:_WordCount_v1.0:~:text=Node%20Setup).-,Source%20Code,-import%20java.io"><strong>Source Code</strong></a>) below the package declaration:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X-YCNH8g7B-2OPuBQ01kHQ.png" /></figure><p>Now let’s generate the jar file by running maven clean package command:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PXcpD3hWVSTzkpsrKXWRLg.png" /></figure><p>This should generate something like <strong>MapReduce-1.0-SNAPSHOT.jar</strong> under the target directory. That’s it, we are now ready to run our first job. For that first we will make sure both <strong>dfs</strong> and <strong>yarn </strong>are running as discussed in step 1.<br> <br> Then we download our input file from (<a href="https://gutenberg.org/files/200/200.txt"><strong>here</strong></a>) and save as 200.txt inside our input folder we created inside the MapReduce project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zgEA8v_AAFN0D2Z1U8GGgg.png" /></figure><p>Now let’s open Terminal inside our Intellij IDE and execute the following commands (Replace <strong>souri</strong> with your PC username):</p><p>Create input directory inside hdfs:<br><strong>hadoop fs -mkdir -p /user/souri/input</strong></p><p>Copy input file from Project directory to hdfs input directory:<br><strong>hadoop fs -put ./input/200.txt /user/souri/input</strong></p><p>Run the jar file in a new job:<br><strong>hadoop jar .\target\MapReduce-1.0-SNAPSHOT.jar org.example.hadoop.wordcount.WordCount input output</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AF7yFtUFglgRlK3VAq3n5g.png" /></figure><p>After successful execution of job you should see a <strong>part-r-00000</strong> file inside output directory inside the <strong>hdfs(</strong><a href="http://localhost:9870/explorer.html"><strong>http://localhost:9870/explorer.html#/user/souri/output</strong></a><strong>)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ksc-fSsfYa_DDbh6EryqKA.png" /></figure><p>Congrats! 👍👏We have just run our first MapReduce job using Hadoop.</p><p><strong>If you are also interested in setting up PySpark natively in Windows, I have added that as a part 2 of this tutorial below:</strong></p><p><a href="https://medium.com/@souringhosh/setting-up-pyspark-natively-on-windows-no-wsl-needed-b171cca9e17e">Setting up PySpark natively on Windows, no WSL needed</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d744771daa6b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up PySpark natively on Windows, no WSL needed]]></title>
            <link>https://medium.com/@souringhosh/setting-up-pyspark-natively-on-windows-no-wsl-needed-b171cca9e17e?source=rss-51d9e237b0fc------2</link>
            <guid isPermaLink="false">https://medium.com/p/b171cca9e17e</guid>
            <category><![CDATA[hadoop]]></category>
            <category><![CDATA[apache-spark]]></category>
            <category><![CDATA[apache-hadoop]]></category>
            <category><![CDATA[introduction-to-pyspark]]></category>
            <category><![CDATA[pyspark]]></category>
            <dc:creator><![CDATA[Sourin Ghosh]]></dc:creator>
            <pubDate>Sat, 14 Feb 2026 08:01:49 GMT</pubDate>
            <atom:updated>2026-02-14T08:24:24.737Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8Az01jhiHY1khZw1L7PHKA.png" /></figure><p><strong>If you are also interested in setting up Hadoop &amp; MapReduce natively in Windows, I have added that as a part 1of this tutorial below:</strong></p><p><a href="https://medium.com/@souringhosh/setting-up-hadoop-natively-on-windows-and-running-your-first-mapreduce-job-no-wsl-needed-d744771daa6b">Setting up Hadoop natively on Windows and running your first MapReduce job, no WSL needed</a></p><h3>Installation and configuration (Apache Spark)</h3><p>Verify whether python is installed</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vxqtRwW-XNzSfNsFlcbqgw.png" /></figure><p>Download tar file from the apache spark link: <a href="https://dlcdn.apache.org/spark/spark-4.1.1/spark-4.1.1-bin-hadoop3.tgz"><strong>https://dlcdn.apache.org/spark/spark-4.1.1/spark-4.1.1-bin-hadoop3.tgz</strong></a><br> <br>Copy the file and paste it in a folder where you want configure it, for example i kept in <strong>C:\Users\souri\dev</strong> <br>Now right click on the file and do extract all:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kJ2ggx3aluwJQhlqAVk2Gw.png" /></figure><p>Open system environment variables and add the <strong>SPARK_HOME</strong> variable. Point to the folder which contains the bin, lib etc folders inside the extracted spark folder, for example for me: <strong>C:\Users\souri\dev\spark-4.1.1-bin-hadoop3\spark-4.1.1-bin-hadoop3</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FViK9HxQ7cyzk9kNEwEHLg.png" /></figure><p>Now add <strong>%SPARK_HOME%\bin</strong> to the <strong>Path</strong> variable:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W5UElc2cha7p3XpZTCGrxg.png" /></figure><p>Now open a <strong>powershell/cmd</strong> window and type <strong>pyspark</strong>. It should output like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GwAiv3uI5144LpyhLi7ijA.png" /></figure><p>Now when we go to <strong>localhost:4040</strong> we should see the following screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UIQOMiHWYvRCLHdy7b-yzg.png" /></figure><p>Congrats! Spark setup is complete and running.</p><h3>Configuring PySpark in PyCharm and running your first program</h3><p>Open Pycharm and create a new PySpark project</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8Axfg96BNjZoW8koqUvF2A.png" /></figure><p>Create data folder inside project to store txt files downloaded from <a href="https://zenodo.org/records/3360392/files/D184MB.zip?download=1"><strong>https://zenodo.org/records/3360392/files/D184MB.zip?download=1</strong></a><br>Extract all txt files and copy inside the data folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RpgsSAUyY9XHIrpsqxCTJQ.png" /></figure><p>Write logic inside main.py to extract the following metadata from the text column of each book in the <strong>books_df</strong> DataFrame:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xQzik7B3eogM80NTUtqFkg.png" /></figure><p>Edit Run Configuration to environment variables needed to run pyspark</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2gMK2Tb95Y-2quOvDlJgWw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yuolA9uJzp19ZTluAdU6ow.png" /></figure><p>Add the following environment variables as per your system:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_1ceuwu2J765Olav6AsSXw.png" /></figure><p>Go to <strong>Pycharm &gt; Settings &gt; Project Structure</strong> and add the following Content Roots present inside your <strong>hadoop\python\lib</strong> folder</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uWlvTnD4bYS6jMKK8Vb9OA.png" /></figure><p>Now let’s run our application</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2ow3xTQxSdvnqKNvDqKykQ.png" /></figure><p>It should output something like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XaXqnMrSmDvaiucEe6itfg.png" /></figure><p>Congrats! 👍👏We have just run our first PySpark program.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b171cca9e17e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Shopware-pwa customization | Vue Storefront UI]]></title>
            <link>https://medium.com/@souringhosh/shopware-pwa-customization-vue-storefront-ui-c2cc2ab68be5?source=rss-51d9e237b0fc------2</link>
            <guid isPermaLink="false">https://medium.com/p/c2cc2ab68be5</guid>
            <category><![CDATA[shopware]]></category>
            <category><![CDATA[vue-storefront]]></category>
            <category><![CDATA[shopware-pwa]]></category>
            <category><![CDATA[shopware-6]]></category>
            <category><![CDATA[shopware-development]]></category>
            <dc:creator><![CDATA[Sourin Ghosh]]></dc:creator>
            <pubDate>Sat, 17 Sep 2022 11:47:30 GMT</pubDate>
            <atom:updated>2022-09-17T13:10:20.413Z</atom:updated>
            <content:encoded><![CDATA[<h3>Shopware pwa customization | Vue Storefront UI</h3><p>Shopware PWA is <strong>a modern JS-based frontend designed for Shopware 6</strong>, making full use of its headless API approach. It is a completely separate and stateless web frontend and can be deployed and replicated over multiple nodes or edge networks.</p><p>For more info visit here: <a href="https://github.com/vuestorefront/shopware-pwa">https://github.com/vuestorefront/shopware-pwa</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*28w0Vw5qKL9QXVbI.png" /><figcaption>Image courtesy: <a href="https://blog.vuestorefront.io/building-shopware-pwa/">https://blog.vuestorefront.io/building-shopware-pwa/</a></figcaption></figure><p><strong>AGENDA<br><em>Today we are going to explore a few ways we can even go further to customise shopware-pwa as per our business requirement to get an awesome e-commerce user experience.</em></strong></p><p>1. Override existing shopware-pwa components and pages.<br>2. Add new composable using Vue composition API to call custom APIs outside of shopware.<br>3. Add new vue components with reusable UI to render data from External APIs via our custom composable.<br>4. Add multilingual support.<br>5. Use the cookie store to save user site info.<br>6. Broadcast custom events and intercept them using useIntercept composable.<br>7. Using Storefront UI readymade components to build an advanced UI.</p><h3><strong>Override existing shopware pwa components</strong></h3><p>· Use npx @shopware-pwa/cli override command<br>· Pick up the component you want to override, Ex: /SwHeaderIcons.vue<br>· The component is being copied from @shopware-pwa/default-theme<br>package, and then placed in src/components ready to edit.<br>· Now your shopware-pwa project uses your local SwHeaderIcons.vue instead of the one from default-theme.</p><p>As demonstrated in the following image: <a href="https://shopware-pwa-docs.vuestorefront.io/assets/img/shopware-pwa-components-override.8994f490.gif">link</a></p><p>Example:<br>We want to override SwHeaderIcons.vue component to hide the person/my account icon when user is not logged in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MrMgjLJ4uiVrOA6v93UvJQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*iyZ8txP7mxWaY2QEwNI-2Q.png" /></figure><p>As we can see a copy of <a href="https://codesandbox.io/s/friendly-sammet-vykovr?file=/src/components/SwHeaderIcons.vue"><strong>SwHeaderIcons.vue</strong></a> has been added under /src/components.</p><p>Now let’s modify the code in this file to get our desired change.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YLCyHdReaWRzQuJIbq1fqA.png" /></figure><p>From</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/533/1*aN4uSxR9GoBqSJGr2oqT9g.png" /></figure><p>To</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/530/1*93PmOsvZ5C3tl1k__TEMTg.png" /></figure><p>After user logged in it is visible as expected</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/541/1*q__P29jqJeGRVIJKLIFPEw.png" /></figure><h3><strong>Add new composable using vue composition api to call custom APIs outside of shopware.</strong></h3><p>Vue composables are a nice way to write reusable logic in your vue app. <a href="https://vuejs.org/guide/extras/composition-api-faq.html">Read More</a></p><p>Shopware pwa already provides many readymade composables to use as listed here: <a href="https://shopware-pwa-docs.vuestorefront.io/landing/resources/api/composables.html">Read More</a></p><p>We want to write a composable in order to call our own APIs and reuse this logic in different components.</p><p>First let’s create a folder composables inside /src.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/537/1*-7CWdYN7AVtFhosYBqb1Sg.png" /></figure><p>Now let’s implement our composable <a href="https://codesandbox.io/s/friendly-sammet-vykovr?file=/src/composables/useCustom.ts"><strong>useCustom.ts</strong></a><strong><br></strong>We will call the catfact api to get some cat facts<strong> </strong>🐱</p><h3><strong>Add new vue components with reusable ui to render data from external APIs</strong></h3><p>Now let’s create our own vue component where we will use our composable to fetch data and render it.</p><p>Create new file <a href="https://codesandbox.io/s/friendly-sammet-vykovr?file=/src/components/SwCustomComponent.vue"><strong>SwCustomComponent.vue</strong></a> under /src/components</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/265/1*58ZRxpMhUqef9IIPAoM93A.png" /></figure><p>We use our composable(useCustom) to get data from our APIs. We can also use this composable in readymade components from shopware-pwa by overriding them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*rzisBTpYzE2ildhP-Z8ALA.png" /></figure><p>With this our custom component SwCustomComponent is complete. Now we use it in different places to display this data.</p><p>For Example:<br>Override <a href="https://codesandbox.io/s/friendly-sammet-vykovr?file=/src/components/SwHeader.vue:1452-1469"><strong>SwHeader</strong></a> component and add the following lines –</p><p>Import the component:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*qavw9ipQ6Qve-qMsYb-LVw.png" /></figure><p>Use it in the UI:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/1*WFMcCsm9sKNqg4LWdP9sBw.png" /></figure><p>Now if we load the homepage we find the Cat fact being rendered from <strong>getCatFacts</strong> API:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ow4hNy6gFa6zGzi63scXEQ.png" /></figure><p>The above customisation code can be found in the following sandbox:</p><blockquote><strong>Do consider opening the sandbox browser in a separate window to get a better experience while viewing the changes. </strong><a href="https://vykovr.sse.codesandbox.io/"><strong>CLICK HERE</strong></a></blockquote><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodesandbox.io%2Fembed%2Frnv8l&amp;display_name=CodeSandbox&amp;url=https%3A%2F%2Fcodesandbox.io%2Fs%2Frnv8l&amp;image=https%3A%2F%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2Frnv8l%2Fscreenshot.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/8fa72fad828fecbad752fc2d4c0caaba/href">https://medium.com/media/8fa72fad828fecbad752fc2d4c0caaba/href</a></iframe><h3><strong>Add multilingual support</strong></h3><p>First configure our shopware sales channel for multilingual support by going into the admin panel as instructed <a href="https://shopware-pwa-docs.vuestorefront.io/landing/cookbook/#_8-how-to-add-another-language">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*ILO7mkJJ-a9TFFOGbL30kw.png" /></figure><p>Now let’s configure our pwa as instructed <a href="https://shopware-pwa-docs.vuestorefront.io/landing/cookbook/#things-that-should-be-done-in-shopware-pwa-app">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/915/1*Y59Ia3XcuzVPuPtgvfVG3A.png" /></figure><p>Now let’s create separate files for each languages under /locales.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*YaFjtXpbb1gPf9n1WyIKOQ.png" /></figure><p>We will copy over all the existing strings from /.shopware-pwa/sw-plugins/locales to the files mentioned above and then add our changes there.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*ywcOJFsZUGtZPVSQKUa_ww.png" /></figure><h3><strong>Use the cookie store to save user site related info</strong></h3><p>In order to use the readymade cookie store provided by shopware-pwa to store our info we first import the application context as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/1*SFqUTtjdSQoZXTcjQZNVeA.png" /></figure><p>Now we access the cookie store(cookies) object from application context.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*uSEFORaHb_483BCY8sOOAw.png" /></figure><p>This is how we get value from cookie store using the key of the stored value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/924/1*lH75BdqJQ75Ai5OUkV4U-g.png" /></figure><p>This is how we set value in cookie using a key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t2A8LA0dkn4WzBm_qcg_7w.png" /></figure><h3><strong>Broadcast custom events and intercept them using useIntercept composable</strong></h3><p>Shopware-pwa provides it’s simple and easy to use <a href="https://shopware-pwa-docs.vuestorefront.io/landing/concepts/interceptor.html#events-interceptor"><strong>Events Interceptor</strong></a> to broadcast events and react to them by updating UI or showing notifications.</p><p>Here’s an example.</p><p>Fire a broadcast on purchase success after order completion.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yc8XJEgxTjsTu5XgZdOViw.png" /></figure><p>Intercept the event(using the event name we set while broadcasting) to update relevant data in some UI component.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*p4cHxMhAK4VClqhEY5KIiw.png" /></figure><h3><strong>Using Storefront UI readymade components to build an advanced UI</strong></h3><p>Shopware-pwa internally uses Vue Storefront-UI, so we get many readymade components to work with in our UI. In this example we look to expand some of the UI capabilities using Storefront-UI components.</p><p>Copy file from /.shopware-pwa/source/pages/account/orders/index.vue and put it inside /src/pages/account/orders/index.vue</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*iHPEQ5lwWoz05h9Gw7nlWw.png" /></figure><p>We are going to add another tab inside Order History section just like the My Orders tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*6v94vNOA2R-gmn0mFvw-fQ.png" /></figure><p>We add a new <strong>&lt;SfTab&gt;</strong> component (from storefront ui) inside <strong>&lt;SfTabs&gt;</strong> to get the new tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*seX84wOoY6HJ-u9yfzxpuw.png" /></figure><p>Checkout more about Storefront UI components <a href="https://docs.storefrontui.io/?path=/story/welcome--page"><strong>here</strong></a><strong><br></strong><a href="https://shopware-pwa-docs.vuestorefront.io/landing/concepts/interceptor.html">Shopware-pwa docs</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c2cc2ab68be5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Keycloak token exchange usage with Google Sign-In]]></title>
            <link>https://medium.com/@souringhosh/keycloak-token-exchange-usage-with-google-sign-in-cd9127ebc96d?source=rss-51d9e237b0fc------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd9127ebc96d</guid>
            <category><![CDATA[google-oauth]]></category>
            <category><![CDATA[keycloakjs]]></category>
            <category><![CDATA[keycloak]]></category>
            <category><![CDATA[identity-management]]></category>
            <category><![CDATA[sso]]></category>
            <dc:creator><![CDATA[Sourin Ghosh]]></dc:creator>
            <pubDate>Tue, 05 Apr 2022 12:04:48 GMT</pubDate>
            <atom:updated>2022-04-06T08:53:45.944Z</atom:updated>
            <content:encoded><![CDATA[<h3>Initialize</h3><p>Today we are going to explore an exciting feature present in <strong>Keycloak</strong>(an Open Source Identity and Access Management solution). <br><strong>Token Exchange</strong> is in Technology Preview and is not fully supported. This feature is disabled by default.</p><blockquote>In order to enable it we need to open <strong>profile.properties</strong> file located at <strong>keycloak\standalone\configuration</strong> and add the following lines :</blockquote><blockquote><strong><em>profile=preview<br>feature.token_exchange=enabled<br>feature.admin_fine_grained_authz=enabled<br>feature.impersonation=enabled</em></strong></blockquote><p>Now restart keycloak by clicking the <strong>standalone.bat</strong> file.</p><h3>Configure Keycloak</h3><h4>Add Realm</h4><p>Create a fresh realm which will hold all users related to your application which uses token-exchange to authenticate them into your system via keycloak.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1005/1*N5IkbeHqsqvNd_gdwXK2bQ.png" /></figure><h4>Create Client</h4><p>We create a client to use it to communicate with google in order to make the token-exchange happen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XzIGJpW9UrxgJFK74_Hphg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4ZqnQ9L26mJLcLQogoZuXg.png" /></figure><h4>Edit Client</h4><p>Enable the client and make the necessary configuration changes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*379-XOBeaR9-aCF12HzC6A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PhATaFZcK190pHbSYirQyA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/893/1*4tDYCnorXAvDtMDG9jLgig.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*oOf9dxqC5Z7tL1vP6-YkFA.png" /></figure><h4>Create exchange policy</h4><p>We need to have an exchange policy setup for the <strong>token-exchange</strong> feature to work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tXZQNjyH9kWKqqRFxv09dQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7cXdd9nc_JTgSUMNjGTDyA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LlKs_ltfy1qTYxCvrn23Lw.png" /></figure><p>Now let’s configure <strong>Google sign-in</strong><br>Go to <a href="https://console.cloud.google.com/">google cloud console</a></p><h4>Create Project</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*mQn4Gb79hkbvnYjwydWftw.png" /></figure><h4>Go to APIs Overview</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*b9Q0eFmneBW_lYhScX3U2A.png" /></figure><h4>Create Credentials</h4><p>We need an OAuth Client which our keycloak client will contact to exchange the token.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4yjA_JqywntKKqVelv8Hcg.png" /></figure><p>But before creating the OAuth Client, creating a <strong>OAuth consent screen</strong> is mandatory. So we do the necessary to set it up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*9ngWY5w7p9cVlvgxK026uA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_5KYnF0Q1huExP6-pr1YIA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WmbZMP2QxFgmxb-bL-XvgQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pi2Obqi4F_Y4_bKCv6xbrA.png" /></figure><p>Once Consent screen is complete we start our Client ID configuration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lEp9GBUmqpl75FuPZxVbRw.png" /></figure><p>We need to add our keycloak url to the <strong>Authorized Javascript origins</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*xKK7ZAG6qLMWGcaDldEgVQ.png" /></figure><h4>Add Identity Provider</h4><p>We now add google as an identity provider in our keycloak where we put in our client ID &amp; client secret copied from our google credentials screen inside Web Client 1.</p><p>Copy from below screen in google cloud console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HuoqB7B9BK6Vr707EGL5sA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PHwsoDYN58Kk1PjtnP7NAA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n7joGJGuQEMwipHvhG1pzQ.png" /></figure><h4>Enable permission for token-exchange</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/661/1*PTXUU451C6mZdL0aeAjjOg.png" /></figure><h4>Add Authorized redirect URIs</h4><p>Add the following to Authorized Redirect URIs in Google Client:</p><p>1. <a href="http://localhost:8080/auth/realms/token_test/broker/google/endpoint">http://localhost:8080/auth/realms/token_test/broker/google/endpoint</a> (&lt;YOUR KEYCLOAK&gt;/auth/realms/&lt;YOUR KEYCLOAK REALM&gt;/broker/google/endpoint)</p><p>2. <a href="http://localhost:8080/auth/realms/token_test/protocol/openid-connect/token">http://localhost:8080/auth/realms/token_test/protocol/openid-connect/token</a> (&lt;YOUR KEYCLOAK&gt;/auth/realms/&lt;YOUR KEYCLOAK REALM&gt;/<a href="http://localhost:8080/auth/realms/token_test/protocol/openid-connect/token">protocol/openid-connect/token</a>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/835/1*yEm3AVLjee4LtHNDlKERzA.png" /></figure><h4>Add Exchange Policy to Client</h4><p>Assign the google-exchange-policy we created earlier to our keycloak client.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rx1THhs5tejVmItFKFtmWg.png" /></figure><h3>Test Keycloak token-exchange API</h3><p>Get google access token from Google OAuth 2.0 Playground</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*wLe2uWt_krhNiM7TXxv6XQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*pRIPNV4JCrZGdIv4dTjP0g.png" /></figure><h4>The Request</h4><p>Use following curl command or import insomnia request to call token exchange API</p><p><a href="https://drive.google.com/file/d/16rkkVfZqm0mcK-yZTw1ReS4BaLCpViDq/view?usp=sharing">Insomnia Request File</a></p><p>curl — request POST \<br> — url http://localhost:8080/auth/realms/&lt;YOUR KEYCLOAK REALM&gt;/protocol/openid-connect/token \<br> — header ‘Content-Type: application/x-www-form-urlencoded’ \<br> — data grant_type=urn:ietf:params:oauth:grant-type:token-exchange \<br> — data subject_token_type=urn:ietf:params:oauth:token-type:access_token \<br> — data client_id=&lt;YOUR KEYCLOAK CLIENT ID&gt; \<br> — data client_secret=&lt;YOUR KEYCLOAK CLIENT SECRET&gt;\<br> — data subject_token=&lt;YOUR GOOGLE ACCESS TOKEN&gt;\<br> — data subject_issuer=&lt;YOUR KEYCLOAK IDENTITY PROVIDER&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cJwOp5TYbP1nvdUPUn6miw.png" /></figure><h4>The Response</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kFl0rkEZl52-64IP8wMIoQ.png" /></figure><h3>Now let’s test the keycloak access token to check if we get the user details from keycloak’s user info API.</h3><h4>The Request</h4><p>curl — request GET \<br> — url <a href="http://localhost:8080/auth/realms/token_test/protocol/openid-connect/userinfo">http://localhost:8080/auth/realms/&lt;YOUR KEYCLOAK REALM&gt;/protocol/openid-connect/userinfo</a> \<br> — header ‘Authorization: Bearer &lt;YOUR KEYCLOAK ACCESS TOKEN&gt;’</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/994/1*hvJwo6QDfYAiHXb2nefcMQ.png" /></figure><h4>The Response</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qpe1ZI769Ge3DSHnt0sk2w.png" /></figure><p><strong><em>That’s it and we are done</em></strong> 🤟🏻🤩</p><p>Important Links: <a href="https://www.keycloak.org/docs/latest/securing_apps/#_token-exchange">Keycloak Doc</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd9127ebc96d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android Quote Span With AppCompat Support Using Both Java and Kotlin]]></title>
            <link>https://medium.com/swlh/android-quote-span-with-appcompat-support-using-both-java-and-kotlin-728b0d75d071?source=rss-51d9e237b0fc------2</link>
            <guid isPermaLink="false">https://medium.com/p/728b0d75d071</guid>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android-apps]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-ui]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Sourin Ghosh]]></dc:creator>
            <pubDate>Fri, 18 Sep 2020 12:32:53 GMT</pubDate>
            <atom:updated>2020-09-23T07:14:08.900Z</atom:updated>
            <content:encoded><![CDATA[<p><em>My 1st publication on Medium, so I am starting off with a short and simple piece of implementation about a problem which I did not find an easy and straight forward solution on Stack Overflow or elsewhere.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/1*Xz6AJyWjhThzcPpyP85O1Q.png" /><figcaption>Sample Quote Span</figcaption></figure><p>This is the easiest way to implement <strong>Android Quote Span</strong> with <strong>customized Stripe width</strong> and <strong>Gap width</strong> without writing your own <strong>Quote Span class</strong> while maintaining <strong>support for Android API level 27 and below</strong>. I am using a <strong>Parcel </strong>to pass the width parameters to the QuoteSpan object.</p><p>If we look at the <a href="https://developer.android.com/reference/android/text/style/QuoteSpan"><strong>QuoteSpan </strong></a>class there are <strong>3 constructors</strong> apart from the default one and only one of them takes the <strong>Stripe width</strong> and <strong>Gap width</strong> parameters in case you need to customize the layout of the QuoteSpan.</p><figure><img alt="public QuoteSpan(int color, int stripeWidth, int gapWidth) {
 throw new RuntimeException(“Stub!”);
 }" src="https://cdn-images-1.medium.com/max/1024/1*dBOlY1XSFckqx9Vni9MTRQ.png" /></figure><p>But when we try to use that constructor for our <strong>customized QuoteSpan</strong> we get an <strong>Error </strong>saying :</p><figure><img alt="This constructor can only be used from API Level 28 and above" src="https://cdn-images-1.medium.com/max/929/1*baR_RcIRzdd8AUMI-fHS4w.png" /><figcaption>API Level 28+ supported only</figcaption></figure><p>This is because we want our Android Application to be supported up to a <strong>Minimum API Level of 23(Marshmallow)</strong> where as this is only supported from <strong>API Level 28(Pie) and above</strong>.</p><p>The usual thing was to search <a href="https://stackoverflow.com/questions/tagged/android"><strong>StackOverflow Android</strong></a> and other sites for an obvious solution. But the solutions I found were a bit complex as it required to <strong>copy the original QuoteSpan class from the SDK and then customize it</strong> with our own implementation which is what I did not want to do.</p><p>So I decided to experiment a bit and started to play around with the QuoteSpan code when I eventually found that the <strong>4th constructor</strong> i.e. which <strong>accepts a Parcel object actually sets those Stripe Width and Gap Width parameters inside it</strong>.</p><figure><img alt="public QuoteSpan(@NonNull Parcel src) {
 mColor = src.readInt();
 mStripeWidth = src.readInt();
 mGap" src="https://cdn-images-1.medium.com/max/435/1*aG_8WFWWdxKU45OvVNrdyQ.png" /></figure><p>I implemented my customized QuoteSpan with the following <strong>Java</strong> code :</p><pre>Parcel parcel = Parcel.obtain();<br>parcel.writeInt(getColor(R.color.colorAccent));//stripe color<br>parcel.writeInt(10);//stripe width<br>parcel.writeInt(10);//gap width<br>parcel.setDataPosition(0);<br>QuoteSpan quoteSpan = new QuoteSpan(parcel);<br>SpannableString string = new  SpannableString(getString(R.string.top_review));<br>string.setSpan(quoteSpan, 0, string.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);<br>((TextView) findViewById(R.id.quoteSpan)).setText(string);<br>parcel.recycle(); // put the parcel object back in the pool</pre><p>And it worked like a charm with <strong>no Android API Level support issues</strong> 😀</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bIIenN81haBfNMysz666Xw.png" /><figcaption>Quote Span Android Preview</figcaption></figure><p>If you want to implement this using <strong>Kotlin</strong> then use this code :</p><pre>val parcel = Parcel.obtain()<br>parcel.writeInt(getColor(R.color.<em>colorAccent</em>))//stripe color<br>parcel.writeInt(10)//stripe width<br>parcel.writeInt(10)//gap width<br>parcel.setDataPosition(0)<br>val quoteSpan = QuoteSpan(parcel)<br>val string = SpannableString(getString(R.string.<em>top_review</em>))<br>string.setSpan(quoteSpan, 0, string.length, Spanned.<em>SPAN_EXCLUSIVE_EXCLUSIVE</em>)<br>findViewById&lt;TextView&gt;(R.id.<em>quoteSpan</em>).<em>text </em>= string<br>parcel.recycle() // put the parcel object back in the pool</pre><p><strong>Please find out the repository and sample Android Application in the following GitHub Link:</strong></p><p><a href="https://github.com/sourin00/Android-Quote-Span-with-AppCompat-">sourin00/Android-Quote-Span-with-AppCompat-</a></p><p><em>Please let me know in the comments if the article helped you or any suggestions you have for me.. Till then Happy Coding</em> 👨‍💻✌</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=728b0d75d071" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/android-quote-span-with-appcompat-support-using-both-java-and-kotlin-728b0d75d071">Android Quote Span With AppCompat Support Using Both Java and Kotlin</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>