<?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 Sang Huynh on Medium]]></title>
        <description><![CDATA[Stories by Sang Huynh on Medium]]></description>
        <link>https://medium.com/@sanghuynh_73086?source=rss-42bfbe9d258------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*C-WE_LvFfIbvxuOJ.</url>
            <title>Stories by Sang Huynh on Medium</title>
            <link>https://medium.com/@sanghuynh_73086?source=rss-42bfbe9d258------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 19:49:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sanghuynh_73086/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[How to access Sharepoint Site using Microsoft Graph?]]></title>
            <link>https://medium.com/@sanghuynh_73086/how-to-access-sharepoint-site-using-microsoft-graph-08d20311c61c?source=rss-42bfbe9d258------2</link>
            <guid isPermaLink="false">https://medium.com/p/08d20311c61c</guid>
            <category><![CDATA[sharepoint-apps]]></category>
            <category><![CDATA[sharepoint-online]]></category>
            <category><![CDATA[microsoft-graph]]></category>
            <category><![CDATA[microsoft-azure]]></category>
            <category><![CDATA[credentials]]></category>
            <dc:creator><![CDATA[Sang Huynh]]></dc:creator>
            <pubDate>Sat, 09 Mar 2024 15:28:24 GMT</pubDate>
            <atom:updated>2024-03-09T15:36:01.180Z</atom:updated>
            <content:encoded><![CDATA[<h3>1. Issue with <strong>AppRegNew</strong></h3><p>In January 2024, I encountered an issue with my current SharePoint App — its credential key had expired, leaving me unable to access the SharePoint Site via API.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2ablQafDu3FbwIIHqaWOAw.png" /></figure><p>I tried to use the old method using <strong>ACS AppRegNew </strong>by this <a href="https://docs.informatica.com/integration-cloud/cloud-data-integration-connectors/current-version/microsoft-sharepoint-online-connector/introduction-to-microsoft-sharepoint-online-connector/administration-of-microsoft-sharepoint-online-connector/generate-the-client-id-and-client-secret.html">link </a>but <strong>it didn’t work.</strong> Compounding the problem, I discovered that this old method is set to be deprecated in April 2026. Hence, it’s necessary to seek out an alternative solution to address this issue promptly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YJpEUL9USKys5aC_sFqg8Q.png" /></figure><p>The old code:</p><pre>&lt;AppPermissionRequests AllowAppOnlyPolicy=&quot;true&quot;&gt;<br>&lt;AppPermissionRequest Scope=&quot;http://sharepoint/content/SiteCollection&quot; Right=&quot;FullControl&quot; /&gt; <br>&lt;/AppPermissionRequests&gt;</pre><h3>2. Solution with Microsoft Graph</h3><p>Seeking a workaround, I’ve found the recommended solution from Microsoft using the new method through Microsoft Graph, accessible via this <a href="https://devblogs.microsoft.com/microsoft365dev/controlling-app-access-on-specific-sharepoint-site-collections/">link</a>. The detailed steps are as follows:</p><h3>2.1. Create an App for controlling Sharepoint Site</h3><ul><li>Access Azure Portal: <a href="https://portal.azure.com/#home">https://portal.azure.com/#home</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MbTUAg6G9yAcCGT7b5m7wA.png" /></figure><ul><li>Select App Registrations → New Registration:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qeQ-QXk29tV76Cz0RhtnvQ.png" /></figure><ul><li>Select option <strong>Single tenant</strong>:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*6qekaSzlYRyM9Q4D7J_nKw.png" /></figure><p>After finishing Registration, your app is created. In my example, it is <strong><em>Test-Sharepoint-Access</em></strong>.</p><p>In <strong>Overview</strong>, we will get <strong>tenant_id </strong>and <strong>client_id </strong>as in the image below. These credentials will be used for the Authentication Step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IjZkJByow1hVFLOAKWeVJg.png" /></figure><h3>2.2. Assign Permission for the App to access the Sharepoint Site</h3><h3>2.2.1. API Permission</h3><ul><li><strong>Microsoft Graph Permission:</strong> Add new permission → Microsoft Graph → Application Permission → Site Selected. This option allows app-only access to a specific Sharepoint Site (selected site).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i-U9RlDkwAZQMn6HlnVXww.png" /></figure><ul><li><strong>Sharepoint Online Permission:</strong> Add new permission → Sharepoint → Application Permission → Site Selected. This option allows app-only access to a specific Sharepoint Site (selected site).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wbsZtChBNjo64xLN88Wbaw.png" /></figure><p>Ask <strong>Azure Portal Admin</strong> (or <strong>IT support</strong>) to <strong><em>grant admin consent for your tenant</em></strong> (Your Company Limited) as in the image below. You also can do this by yourself if your account is Microsoft Admin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zlQ3buAMPOUhlzPxmbyFrw.png" /></figure><p>After granting permission, the status column should be green as below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fYeBsLhtt3tN9H_lPaEx_g.png" /></figure><h3>2.2.2. Assign the App to the selected Sharepoint Site by using PnP PowerShell</h3><ul><li>Open PowerShell (recommended to use version &gt;= 7.x to run code) in local.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1002/1*7heGTaxGhXlOcODGVqVVUg.png" /></figure><ul><li>If you haven’t <strong>PnP PowerShell</strong> locally, use the following command to install it:</li></ul><pre>### Install PnP PowerShell in local PowerShell:<br>Install-Module PnP.PowerShell -Scope CurrentUser<br>Install-Module SharePointPnPPowerShellOnline -Scope CurrentUser</pre><ul><li>Connect Sharepoint Site Online:</li></ul><pre>### Connect Sharepoint Online:<br>$devAsiaP = &quot;https://trustonic.sharepoint.com/sites/FinanceReporting&quot;<br>Connect-PnPOnline -Url $devAsiaP</pre><ul><li>Verify connection:</li></ul><pre>### Verify connection:<br>Get-PnPSite</pre><ul><li>Grant permission (<em>Permissions Write</em>) for the selected site.</li></ul><pre>### Grant permission for selected site:<br>Grant-PnPAzureADAppSitePermission -AppId &quot;{client_id}&quot; -DisplayName &quot;{app_name}&quot; -Permissions Write -Site https://trustonic.sharepoint.com/sites/FinanceReporting</pre><ul><li>Granted permission successfully:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q0XIUMFbILBKzgwPtlMVvA.png" /></figure><p>After this step, our created app already has permission to control the selected Sharepoint Site.</p><h3>2.3. Generate Credentials with Certificate</h3><p>There are two ways to use Credentials for accessing Sharepoint Site including the secret key method and the certificate method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dktL7AJabG27lwfwESXQdA.png" /></figure><p>However, the secret key authentication method did not work in my case. Then, I did some research and got the recommendation to use the <strong>certificate method </strong>as this link<strong> — </strong><a href="https://github.com/AzureAD/azure-activedirectory-library-for-python/wiki/Client-credentials#client-credentials-with-certificate">Client credentials</a>.</p><ul><li><strong>Generate a key:</strong></li></ul><pre>openssl genrsa -out server.pem 2048</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*owHka4lhxgIjrK75pZzkpQ.png" /></figure><ul><li><strong>Create a certificate request:</strong></li></ul><pre>openssl req -new -key server.pem -out server.csr</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*k5KIOn2N54wMPLziJE1gtg.png" /></figure><ul><li><strong>Generate a certificate:</strong></li></ul><pre>openssl x509 -req -days 365 -in server.csr -signkey server.pem -out server.crt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1003/1*ICjgLby0Fho0sVD_fNKXsQ.png" /></figure><p>Your certificates are saved as below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bgx1ALIVidRrLNRBH-wlDQ.png" /></figure><h3>2.4. Upload certificate on Azure Portal</h3><p>You will have to upload this certificate (server.crt) on <strong>Azure Portal </strong>in your application settings. Once you save this certificate, the portal will give you the <strong>thumbprint </strong>of this certificate which is needed in the acquire token call. The key will be the server.pem key you generated in the first step.</p><p><strong>Detail Steps:</strong> Azure Portal → App Registration → Select your App → Certificates &amp; Secrets (on the left menu) → Upload <strong>server.crt </strong>file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fG67U8Sq7TYhmv1ueuj6Kw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IMZMSRp50oP6QAkkpXo7Gw.png" /></figure><h3>2.5. Use certificates to access Sharepoint</h3><p>Now you can create the credential for the client credential flow using the certificate in ADAL Python as follows:</p><pre>client_credentials = {<br>    &quot;client_id&quot;: &lt;your app id&gt;,<br>    &quot;thumbprint&quot;: &lt;thumbprint of cert file&gt;,<br>    &quot;certificate&quot;: &lt;server.pem&gt;<br> }</pre><pre>from office365.sharepoint.client_context import ClientContext<br># Create a ClientContext using the AuthenticationContext<br>client_context = ClientContext(site_url).with_client_certificate(        <br>        tenant = &#39;yourcompany.com&#39;,<br>        client_id = client_id,<br>        thumbprint = cert_thumbprint,<br>        private_key=private_key)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CcPLCuMTTJdQETtSu9U8mg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7mpKCV1oqLx9qc3nss4X8g.png" /></figure><h3><strong>**THANKS FOR READING!***</strong></h3><h3>***References:</h3><ul><li><a href="https://devblogs.microsoft.com/microsoft365dev/controlling-app-access-on-specific-sharepoint-site-collections/">https://devblogs.microsoft.com/microsoft365dev/controlling-app-access-on-specific-sharepoint-site-collections/</a></li><li><a href="https://docs.informatica.com/integration-cloud/cloud-data-integration-connectors/current-version/microsoft-sharepoint-online-connector/introduction-to-microsoft-sharepoint-online-connector/administration-of-microsoft-sharepoint-online-connector/generate-the-client-id-and-client-secret.html">https://docs.informatica.com/integration-cloud/cloud-data-integration-connectors/current-version/microsoft-sharepoint-online-connector/introduction-to-microsoft-sharepoint-online-connector/administration-of-microsoft-sharepoint-online-connector/generate-the-client-id-and-client-secret.html</a></li><li><a href="https://www.youtube.com/watch?v=SNIF3zCYNUk">https://www.youtube.com/watch?v=SNIF3zCYNUk</a></li><li><a href="https://github.com/AzureAD/azure-activedirectory-library-for-python/wiki/Client-credentials#client-credentials-with-certificate">https://github.com/AzureAD/azure-activedirectory-library-for-python/wiki/Client-credentials#client-credentials-with-certificate</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=08d20311c61c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to install LabelImg in Windows with Anaconda?]]></title>
            <link>https://medium.com/@sanghuynh_73086/how-to-install-labelimg-in-windows-with-anaconda-c659b27f0f?source=rss-42bfbe9d258------2</link>
            <guid isPermaLink="false">https://medium.com/p/c659b27f0f</guid>
            <category><![CDATA[image-annotation]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[labeling]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[image-recognition]]></category>
            <dc:creator><![CDATA[Sang Huynh]]></dc:creator>
            <pubDate>Wed, 13 May 2020 04:10:06 GMT</pubDate>
            <atom:updated>2021-09-05T10:13:47.163Z</atom:updated>
            <content:encoded><![CDATA[<h3>1. What is Data labeling?</h3><p>One of the most important part in the data science process is data pre-processing which makes data scientists put lots of time and effort into. Particularly, in the context of machine learning, data pre-processing requires a step of labeling. This is the step to detect and label data sample into multi-classifications so that the labeled data can be used in further machine learning process. Two typical labeling data type in ML projects are text and image annotation. The former is the crucial step in NLP projects such as sentiment analysis and the latter is the required part in computer vision projects. Labeling process is normally handled by manual, but it can be assisted by some applications to reduce the working-time. In this article, I will introduce <strong>LabelImg </strong>— an image annotation tool which is quite simple and easy-to-use for the beginner or non-technical guys who are concerning about how to do computer vision projects.</p><h3>2. What is LabelImg?</h3><p><strong>LabelImg </strong>is a graphical image annotation tool which provides images with bounding boxes after labeling. It is written in Python and uses Qt (one of the most common GUI for python) for its graphical interface. The output labeled data are saved as XML files in PASCAL VOC format, the format used by ImageNet. Also, YOLO format is supported in this tool.</p><p>Below are the LabelImg User Interfaces when opening:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Bg0Gucei8cVFlxzk" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aVbwZpdKtt5Pkkd0" /></figure><h3>3. Why do we use LabelImg?</h3><ul><li>It is open-source then it is free to use.</li><li>It has both online and offline versions. The offline interface is user-friendly and allows the user to make fast annotations.</li><li>The output annotation images are saved separately as XML files along with Pascal VOC format or YOLO format. These are common formats supported by many ML packages.</li><li>After installation, it is easy to use with simple instructions.</li><li>It can process a large number of images when compared to other free apps such as <strong>Cloud Vision API</strong> (the free-offline version is limited up to only 2000 image files) or <strong>Labelbox </strong>(the free version only allows maximum of 5000 images to be processed).</li><li>It can be run in multiple operating systems such as Linux, Mac or Windows.</li><li>It is written in Python then it can interact with other python packages and is easy to be used in python applications for further development.</li></ul><p>However, this tool still has some limitations:</p><ul><li>Bounding box (rectangle shape) is the only region shape to be used. Therefore, it cannot give an exactly detection for complicated objects with curved lines…</li><li>The installation requires some tricks we need to know. Therefore, I will present how to install this tool step by step in the next session.</li></ul><h3>3. Installation.</h3><h3>3.1. Prerequisites.</h3><p>The installation below is used for <strong>Windows OS </strong>with <strong>Anaconda</strong>. Therefore, we need to install <strong>Anaconda</strong> to have an <strong>Anaconda terminal</strong>.</p><p>Follow the link below to install <strong>Anaconda</strong> in Windows:</p><p><a href="https://docs.anaconda.com/anaconda/install/windows/">https://docs.anaconda.com/anaconda/install/windows/</a></p><h3>3.2. Installing LabelImg in Windows with Anaconda.</h3><ul><li>Install <strong>Anaconda</strong> as described in the above session.</li><li>Create a new environment in <strong>Anaconda</strong>.</li></ul><p>We should create a new environment instead of using the base environment in <strong>Anaconda</strong> to avoid conflict of versions while installing the packages. Because the current <strong>LabelImg </strong>packages requires the older version of python (&lt; 3.8.x). Therefore, creating a new separate environment can avoid the error conflict when there are two versions of python in a same environment.</p><p>Do the following commands:</p><pre>conda create -n env_name<br>conda activate env_name</pre><p>E.g:</p><pre>conda create -n labelimg<br>conda activate labelimg</pre><h3>3.3. Install python/tensorflow.</h3><p>Please note that we only install the python version which is older than 3.8.x because the latest tensorflow version is not compatible with python version &gt; 3.8.0.</p><p>Do the following commands:</p><ul><li>Install python (version &lt; 3.8.x):</li></ul><pre>conda install python=3.7.0</pre><ul><li>Install tensorflow:</li></ul><pre>conda install tensorflow<br># this command will install the latest version of tensorflow</pre><h3>3.4. Install pyqt and lxml.</h3><p>These are prerequisite packages needed to be imported before running labelImg.</p><ul><li>Install pyqt 5:</li></ul><pre>conda install pyqt=5</pre><ul><li>Install lxml:</li></ul><pre>conda install -c anaconda lxml</pre><h3>3.5. Install labelImg package.</h3><ul><li>Download package github labelImg from <a href="https://github.com/tzutalin/labelImg">https://github.com/tzutalin/labelImg</a> and extract into folder.</li><li>Change the current directory to the folder of <strong>labelImg.</strong></li></ul><pre>cd <strong>path_to_lablelImg_folder</strong></pre><p>e.g:</p><pre>cd C:\Users\sang.huynh\Documents\SANG\labelImg</pre><ul><li>Do the following command:</li></ul><pre>pyrcc5 -o resources.py resources.qrc</pre><p>Also, to avoid manually changing the location of resources.py file, we can use the command below instead (as suggested by Jaggu):</p><pre>pyrcc5 -o libs/resources.py resources.qrc</pre><p>This command will create a <strong>resource.py </strong>file in folder <strong>labelImg</strong>. This file will be moved to the libs folder in the next step.</p><ul><li>Change the location of <strong>resources.qrc</strong> and <strong>resource files</strong> to <strong>libs </strong>folder<strong> </strong>(libs folder is in labelImg folder). Please note that this step is very important to have a successful installation of <strong>labelImg</strong>.</li><li>Finally, do the below command:</li></ul><pre>python labelImg.py</pre><p>Then it opens a window of <strong>labelImg</strong> app. In View menu, tick Auto Save Mode — this will make the output files are automatically saved in Dir Folder. Output files are saved in XML format as default.</p><h3>4. Open labelImg after the first installation.</h3><ul><li>Open anaconda terminal;</li><li>Change the current directory to the<strong> labelImg</strong> folder (please remember to change the current directory path in anaconda to the <strong>labelImg</strong> folder when opening this tool):</li></ul><pre>cd <strong>path_to_lablelImg_folder</strong></pre><ul><li>Do the follow command:</li></ul><pre>python labelImg.py</pre><p><strong>**THANKS FOR READING!***</strong></p><p><strong>***References:</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FVsZvT69Ssbs%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DVsZvT69Ssbs&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FVsZvT69Ssbs%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/0c8f9187f4a98d4c46788ef54838f645/href">https://medium.com/media/0c8f9187f4a98d4c46788ef54838f645/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c659b27f0f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>