<?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 Abhiruchi Chaudhari on Medium]]></title>
        <description><![CDATA[Stories by Abhiruchi Chaudhari on Medium]]></description>
        <link>https://medium.com/@abhiruchichaudhari?source=rss-3b428a3363f6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*EV_G66z8viDwGy8Kk4zmzw.jpeg</url>
            <title>Stories by Abhiruchi Chaudhari on Medium</title>
            <link>https://medium.com/@abhiruchichaudhari?source=rss-3b428a3363f6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 02:04:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@abhiruchichaudhari/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[Building a Cloud-Based Social Media Sentiment Analysis System with Oracle Cloud Infrastructure]]></title>
            <link>https://medium.com/@abhiruchichaudhari/building-a-cloud-based-social-media-sentiment-analysis-system-with-oracle-cloud-infrastructure-65561275c31e?source=rss-3b428a3363f6------2</link>
            <guid isPermaLink="false">https://medium.com/p/65561275c31e</guid>
            <dc:creator><![CDATA[Abhiruchi Chaudhari]]></dc:creator>
            <pubDate>Tue, 02 Sep 2025 22:34:05 GMT</pubDate>
            <atom:updated>2025-09-02T22:34:05.283Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>Introduction</strong></h4><blockquote>💬 Social media platforms generate millions of conversations every day. From product reviews to political debates, these conversations hold a treasure of insights about how people feel. 🔍 Analyzing this data can help companies monitor brand perception, track trending topics, and make data-driven decisions.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qvNWnSHGUbYeUakDmlFE6g.png" /></figure><p>In this project, a ☁️ <strong><em>cloud-based sentiment analysis plugin</em> </strong>is built<strong> </strong>using <strong><em>Oracle Cloud Infrastructure (OCI)</em></strong> that fetches live tweets from <strong><em>Twitter</em></strong>, processes them for sentiment analysis 📊, and visualizes real-time insights in <strong><em>Oracle Analytics Cloud (OAC)</em></strong></p><h4>Why do we need such a system?</h4><p>⚡ Manually scanning thousands of tweets to understand public opinion is impossible. Businesses need <strong><em>real-time, automated, and scalable systems</em></strong> that can:</p><ul><li>🔄 Continuously fetch social media data.</li><li>😊😐☹️ Analyze it for sentiment (positive/negative/neutral).</li><li>🔐 Store and secure the results.</li><li>📈 Present findings in a clear and visual way.</li></ul><p>️This project addresses exactly that 🛠️</p><blockquote>The <strong><em>Social Media Sentiment Analysis Plugin</em></strong> automates the process of fetching tweets, analyzing them, and presenting results in dashboards.</blockquote><p>Here’s the architecture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*NFd951RSE9NeC1UkLOncIg.png" /><figcaption>Architecture Overview of Sentiment Analysis Plugin with OAC &amp; OCI</figcaption></figure><p>This diagram illustrates the end-to-end architecture of the <strong><em>Social Media Sentiment Analysis Plugin</em></strong> deployed on <strong><em>Oracle Cloud Infrastructure (OCI)</em></strong>.</p><ul><li>👤 <strong><em>Actor (User/OCI Console)</em></strong> enables the plugin via <strong><em>Oracle Analytics Cloud (OAC)</em></strong><em>.</em></li><li>➡️ Requests are routed through an <strong><em>API Gateway</em></strong> 🌐 to a <strong><em>Serverless Function </em></strong>⚡, which fetches data (e.g., tweets) and processes them 🧠</li><li>🔐 <strong><em>Key Vault</em></strong> securely stores and manages database credentials.</li><li>🗄️ The processed data is stored in an <strong><em>Autonomous Transaction Processing (ATP) Database</em></strong><em>.</em></li><li>📊 <strong><em>Oracle Analytics Cloud Data Pipeline (OAC DP</em>)</strong> consumes the data for real-time visualization and dashboards 📈</li><li>🛡️ The deployment is secured and managed using <strong><em>VCN (Virtual Cloud Network </em></strong>☁️<strong><em>), Security Lists </em></strong>🔒<strong><em>, Route Tables </em></strong>🛣️<strong><em>, IAM policies </em></strong>👥<strong><em>, and Registry </em></strong>📦 for container images.</li></ul><p>This architecture provides a <strong><em>scalable </em></strong>📏<strong><em>, secure </em></strong>🔐<strong><em>, and automated pipeline </em></strong>🤖 for fetching, analyzing, and visualizing social media sentiment using Oracle Cloud☁️</p><h4>⚙️ Implementation Details</h4><p><strong>1. Data Ingestion</strong></p><ul><li>🌐 Integrated with the <strong><em>Twitter API</em></strong> to fetch live tweets.</li><li>🔑 Used <strong><em>OCI API Gateway</em></strong> to handle requests securely.</li><li>⚡ Built <strong><em>OCI Functions</em></strong> to run serverless code for data collection and pre-processing.</li></ul><p><strong>2. Data Processing</strong></p><ul><li>🤖 Applied sentiment analysis logic to classify tweets as positive, negative, or neutral.</li><li>📝 Implemented basic text processing (tokenization, keyword checks, scoring).</li></ul><p><strong>3. Storage</strong></p><ul><li>🗄️ Stored processed tweets in <strong><em>Autonomous Transaction Processing (ATP) Database</em></strong><em>.</em></li><li>🔐 Configured <strong><em>OCI Key Vault</em></strong> to manage DB passwords securely.</li></ul><p><strong>4. Visualization</strong></p><ul><li>📊 Integrated <strong><em>Oracle Analytics Cloud (OAC)</em></strong> with the ATP database.</li><li>Built interactive dashboards to visualize:</li></ul><blockquote>📌 Sentiment distribution.</blockquote><blockquote>🔑 Trending keywords.</blockquote><blockquote>⏱️ Time-based sentiment shifts.</blockquote><p><strong>5. Security &amp; Infrastructure</strong></p><ul><li>🔒 Deployed system inside a <strong><em>VCN (Virtual Cloud Network)</em></strong><em>.</em></li><li>⚙️ Configured <strong><em>Security Lists</em></strong> and <strong><em>Route Tables</em></strong> for safe communication.</li><li>👤 Used <strong><em>IAM</em></strong> for fine-grained access control.</li></ul><h3>🎥 Demo / Results</h3><p>Here’s the working demo of the plugin:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FtS-yMUTMIkc%3Fstart%3D7%26feature%3Doembed%26start%3D7&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DtS-yMUTMIkc&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FtS-yMUTMIkc%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/bdfa13e364abf9e59ef3897613ebd26e/href">https://medium.com/media/bdfa13e364abf9e59ef3897613ebd26e/href</a></iframe><p>The dashboard provides instant visualizations 📊 of how sentiment trends evolve in real time based on Twitter data 🐦</p><h4>🔹 <strong>Key Learnings</strong></h4><p>Working on this project helped me strengthen:</p><ul><li>💻 <strong>Backend Development</strong> → writing serverless functions, integrating APIs.</li><li>☁️ <strong>Cloud Services</strong> → deploying and scaling applications on <strong><em>OCI</em></strong>.</li><li>🔄 <strong>Data Pipeline Design</strong> → end-to-end flow from ingestion → processing → visualization.</li><li>🔐 <strong>Security Best Practices</strong> → using Key Vault and IAM for credentials and permissions.</li></ul><h4><strong>🔹 Conclusion</strong></h4><p>This project was an excellent opportunity to combine <strong>backend engineering, cloud architecture, and data analytics</strong> into one end-to-end system. It demonstrates how real-time social media data can be turned into <strong>actionable insights</strong> with cloud technologies.</p><p>Check out the full source code here:</p><p><a href="https://github.com/abhii1101/Social-Media-Sentiment-Analysis-Plugin/tree/main">GitHub - abhii1101/Social-Media-Sentiment-Analysis-Plugin: Cloud system that enables the power of Oracle Cloud Infrastructure to fetch the data from Twitter, analyse it, get interesting insights and visualise it in Oracle Analytics Cloud</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=65561275c31e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OAuth 2.0 Tokens and Twitter API: Everything You Need to Know]]></title>
            <link>https://medium.com/@abhiruchichaudhari/oauth-2-0-tokens-and-twitter-api-everything-you-need-to-know-bddaf9a7f120?source=rss-3b428a3363f6------2</link>
            <guid isPermaLink="false">https://medium.com/p/bddaf9a7f120</guid>
            <category><![CDATA[authorization-grant]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[oauth2]]></category>
            <category><![CDATA[twitter-api]]></category>
            <category><![CDATA[authentication-protocol]]></category>
            <dc:creator><![CDATA[Abhiruchi Chaudhari]]></dc:creator>
            <pubDate>Wed, 19 Apr 2023 17:33:46 GMT</pubDate>
            <atom:updated>2025-09-02T23:29:57.822Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KKk3v-KMCg5hafZCcX81Ew.png" /></figure><h4>OAuth2 flow for Twitter</h4><pre>+--------+                                   +---------------+<br>|        |--(A)- Authorization Request -&gt;    |               |<br>|        |                                   |               |<br>|        |&lt;-(B)-- Authorization Grant -------|               |<br>|        |                                   |               |<br>|        |                                   | Authorization |<br>|        |                                   |     Server    |<br>|        |                                   |               |<br>|        |--(C)-- Authorization Grant --&gt;    |               |<br>|        |                                   +---------------+<br>|        |           <br>|        |                                   +---------------+<br>|        |--(D)-- Access Token Request --&gt;   |               |<br>|        |                                   |               |<br>|        |&lt;-(E)------ Access Token --------- |               |<br>|        |                                   |   Resource    |<br>|        |                                   |     Server    |<br>|        |                                   |               |<br>|        |--(F)------ Access Token ------&gt;   |               |<br>|        |                                   +---------------+<br>|        |</pre><h4><em>Steps :</em></h4><ol><li><em>Create </em><a href="https://www.youtube.com/redirect?event=video_description&amp;redir_token=QUFFLUhqbE1mb3hxRlpsRWt5UkUyOW1IZnlEUjN0WlVWd3xBQ3Jtc0tsRDR6OGpRTkZQV1BXb05rbEJreHJuSFdmakdxLTBYTWlnZ2FnLUE5VWc5c3ZOdGd4VkxHcW9XYzlRX3ItNWM1WG1sd3g5SHR5a1NjcjJodGYtU1NWV09MZnFWa3haZmZScjBDSXl4Z09SeGdsbk1Jcw&amp;q=https%3A%2F%2Fdeveloper.twitter.com%2Fen%2Fapply-for-access&amp;v=3TIoQu-tHZs"><em>Twitter developer account</em></a><em> and verify phone number.</em></li><li><em>Enter your usecase and agree to their terms.</em></li><li><em>You will be directed to Twitter Dashboard with a project created.</em></li><li><em>Click on keys &amp; tokens -&gt; Regenerate API Key &amp; Secret under Consumer Keys and Bearer Token , Access Token &amp; Secret under Authentication Tokens and save it for future use.</em></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1erBfkfiUhA97NQtsboxXw.png" /></figure><p><em>5. Go to the project in developer portal and setup user authentication</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*60vEvpG6pY8AoqSt926gVQ.png" /></figure><p><em>6. Give the app permission to Read and write and direct message</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K3fuKsibrek8216X7xfUJw.png" /></figure><p><em>Type of app -&gt; Native App</em></p><p><em>7. In the app info, add </em><a href="http://127.0.0.1/"><em>http://127.0.0.1</em></a><em> in the callback uri</em></p><p><em>Add website url as seen in your browser</em></p><pre>https://developer.twitter.com/en/portal/projects/1648328711593181184/apps/26952311/auth-settings</pre><p><em>change auth-settings in the last to settings</em></p><pre>https://developer.twitter.com/en/portal/projects/1648328711593181184/apps/26952311/settings</pre><p><em>and save it.</em></p><p><em>8. On completing this steps, you will get Client ID &amp; Client Secret.</em></p><p><em>9. Add the Client ID generated from step 8 to the following url and get the authorization code from the browser</em></p><pre>https://twitter.com/i/oauth2/authorize?response_type=code&amp;client_id=&lt;client-id&gt;&amp;redirect_uri=http://127.0.0.1&amp;scope=tweet.read%20users.read%20follows.read%20offline.access&amp;state=state&amp;code_challenge=challenge&amp;code_challenge_method=plain</pre><p><em>You will be asked to Authorize the app so that third-party application can access your Twitter data on your behalf.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j06u1hMzpZPtDyJbvUyYHg.png" /></figure><p><em>User will be redirected to Twitter’s authorization URL, which looks like this</em></p><pre>http://127.0.0.1/?state=state&amp;code=TEsjdajdbhahbMQm92ODE4MzAzNzI2Nzc6MToxOmFjOjE</pre><p><em>Tip : There is 30 sec expiry limit on the authorization code generated from the browser.</em></p><p><em>10. Generate Access Token</em></p><p><em>Make a curl request to </em><a href="https://api.twitter.com/2/oauth2/token"><em>https://api.twitter.com/2/oauth2/token</em></a><em> with authorization code got from step 9 and Client ID within 30 seconds of the code generation</em></p><pre>curl --location &#39;https://api.twitter.com/2/oauth2/token&#39; \<br>--header &#39;Content-Type: application/x-www-form-urlencoded&#39; \<br>--header &#39;Cookie: guest_id=v1%3A166539399762736297; guest_id_ads=v1%3A166539399762736297; guest_id_marketing=v1%3A166539399762736297; personalization_id=&quot;v1_VfKYUIP1Z7FdzmaqEs4KTw==&quot;&#39; \<br>--data-urlencode &#39;code=&lt;authorization-code&gt;&#39; \<br>--data-urlencode &#39;grant_type=authorization_code&#39; \<br>--data-urlencode &#39;client_id=&lt;client-id&gt;&#39; \<br>--data-urlencode &#39;redirect_uri=http://127.0.0.1&#39; \<br>--data-urlencode &#39;code_verifier=challenge&#39;</pre><p><em>You will get json response of following type</em></p><pre>{<br>    &quot;token_type&quot;: &quot;bearer&quot;,<br>    &quot;expires_in&quot;: 7200,<br>    &quot;access_token&quot;: &quot;WWxlQnkzdWczMmdUZXo4d2514MTY6MToxOmF0OjE&quot;,<br>    &quot;scope&quot;: &quot;users.read follows.read tweet.read offline.access&quot;,<br>    &quot;refresh_token&quot;: &quot;X0ZaTWJHBvRGZselk3bGZNa1dZMHlBOjE2ODE4MzA5NTEnJ0OjE&quot;<br>}</pre><p><em>11. Access Twitter’s data using the Access Token</em></p><ul><li><em>Get single Tweet by Tweet ID</em></li></ul><pre>curl --location &#39;https://api.twitter.com/2/tweets/1307290179556630528&#39; \<br>--header &#39;Authorization: Bearer &lt;access-token&gt;&#39; \<br>--header &#39;Cookie: guest_id=v1%3A166539399762736297; guest_id_ads=v1%3A166539399762736297; guest_id_marketing=v1%3A166539399762736297; personalization_id=&quot;v1_VfKYUIP1Z7FdzmaqEs4KTw==&quot;&#39;</pre><p><em>Json response:</em></p><pre>{<br>    &quot;data&quot;: {<br>        &quot;edit_history_tweet_ids&quot;: [<br>            &quot;1307290179556630528&quot;<br>        ],<br>        &quot;id&quot;: &quot;1307290179556630528&quot;,<br>        &quot;text&quot;: &quot;Brothers in the air 😃 @ABdeVilliers17 https://t.co/hf0oeB9Z0h&quot;<br>    }<br>}</pre><ul><li><em>Get multiple tweets by Tweet ID</em></li></ul><pre>curl --location &#39;https://api.twitter.com/2/tweets?ids=1579329448390037504%2C1307290179556630528%2C1575743933799243777%2C1576643915322564609%2C1579397173464117249%2C1579324694041591808&#39; \<br>--header &#39;Authorization: Bearer &lt;access-token&gt;&#39; \<br>--header &#39;Cookie: guest_id=v1%3A166539399762736297; guest_id_ads=v1%3A166539399762736297; guest_id_marketing=v1%3A166539399762736297; personalization_id=&quot;v1_VfKYUIP1Z7FdzmaqEs4KTw==&quot;&#39;</pre><p><em>The following collection contains the curl request for data of lookup tweets, users by ID or username, followers or following of the user, list of tweets, list of members, create/delete tweet, recent search, full archive search, liked tweets and many more..</em></p><p><a href="https://www.postman.com/gold-zodiac-140027/workspace/abhiruchi-oauth-postman-collection/collection/20917539-68c3dcf9-a456-42e2-99d5-169f87e4c8f5?action=share&amp;creator=20917539">Twitter API v2 | Abhiruchi OAuth Postman Collection</a></p><p><em>Token uri : </em><a href="https://api.twitter.com/oauth/request_token"><em>https://api.twitter.com/oauth/request_token</em></a></p><p><em>Auth uri : </em><a href="https://api.twitter.com/oauth/authorize"><em>https://api.twitter.com/oauth/authorize</em></a></p><h4><strong><em>Troubleshooting</em></strong></h4><ul><li><em>If you are getting such error</em></li></ul><pre>{<br>    &quot;client_id&quot;: &quot;96251321&quot;,<br>    &quot;detail&quot;: &quot;When authenticating requests to the Twitter API v2 endpoints, you must use keys and tokens from a Twitter developer App that is attached to a Project. You can create a project via the developer portal.&quot;,<br>    &quot;registration_url&quot;: &quot;https://developer.twitter.com/en/docs/projects/overview&quot;,<br>    &quot;title&quot;: &quot;Client Forbidden&quot;,<br>    &quot;required_enrollment&quot;: &quot;Appropriate Level of API Access&quot;,<br>    &quot;reason&quot;: &quot;client-not-enrolled&quot;,<br>    &quot;type&quot;: &quot;https://api.twitter.com/2/problems/client-forbidden&quot;<br>}</pre><p><em>Resolution : Create a Project via the Twitter Developer Portal and then attach a Twitter developer App to it. Navigate to the project by clicking on the project name in the “Projects &amp; Apps” tab and delete the old app. Create new app , get your keys &amp; tokens , go to App settings and follow all the steps from step 5.</em></p><h4>References</h4><p><a href="https://developer.twitter.com/en/docs/authentication/oauth-2-0/user-access-token">OAuth 2.0 Making requests on behalf of users</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F3TIoQu-tHZs%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D3TIoQu-tHZs&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F3TIoQu-tHZs%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/3453ddf3818d5c9fcbe012d0b0ea5eb4/href">https://medium.com/media/3453ddf3818d5c9fcbe012d0b0ea5eb4/href</a></iframe><p><a href="https://stackoverflow.com/questions/19095257/using-twython-to-send-a-tweet-twitter-api-error/19196583#19196583">Using Twython to send a tweet, twitter api error</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bddaf9a7f120" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OAuth 2.0 Documentation]]></title>
            <link>https://medium.com/@abhiruchichaudhari/oauth-2-0-documentation-d923e1470c08?source=rss-3b428a3363f6------2</link>
            <guid isPermaLink="false">https://medium.com/p/d923e1470c08</guid>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[access-token]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[authorization]]></category>
            <category><![CDATA[oauth2]]></category>
            <dc:creator><![CDATA[Abhiruchi Chaudhari]]></dc:creator>
            <pubDate>Tue, 18 Apr 2023 12:33:35 GMT</pubDate>
            <atom:updated>2023-04-19T17:52:18.226Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Quickguide for all your OAuth supported datasources …</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3vixFYZVlSkCvwW-n7fzCA.jpeg" /></figure><blockquote>OAuth 2.0 is an secured authorization protocol used for granting third-party applications limited access to a user’s resources on a web service without exposing their login credentials. OAuth 2.0 defines a set of roles, scope, grant types and endpoints where user is prompted to authorize the third-party application on redirection. It relies on the use of access tokens and refresh tokens issued by OAuth provider which enable applications to obtain limited access to protected resources on their behalf.</blockquote><h4>Google Analytics</h4><p><a href="https://medium.com/@abhiruchichaudhari/oauth-2-0-for-google-analytics-d0d121a68259">OAuth 2.0 for Google Analytics</a></p><h4>Twitter</h4><p><a href="https://medium.com/@abhiruchichaudhari/oauth-2-0-tokens-and-twitter-api-everything-you-need-to-know-bddaf9a7f120">OAuth 2.0 Tokens and Twitter API: Everything You Need to Know</a></p><p><em>Will be adding other datasources soon.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d923e1470c08" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OAuth 2.0 for Google Analytics]]></title>
            <link>https://medium.com/@abhiruchichaudhari/oauth-2-0-for-google-analytics-d0d121a68259?source=rss-3b428a3363f6------2</link>
            <guid isPermaLink="false">https://medium.com/p/d0d121a68259</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[access-token]]></category>
            <category><![CDATA[oauth2]]></category>
            <category><![CDATA[google-analytics]]></category>
            <category><![CDATA[authentication]]></category>
            <dc:creator><![CDATA[Abhiruchi Chaudhari]]></dc:creator>
            <pubDate>Tue, 18 Apr 2023 12:27:56 GMT</pubDate>
            <atom:updated>2023-04-19T17:15:56.105Z</atom:updated>
            <content:encoded><![CDATA[<p>OAuth 2.0 can be used to authorize a third-party application to access a user’s Google Analytics data</p><pre>    +-----------------+                                         +-------------------------------------+<br>    |    Third-Party  |                                         |       Google Authorization Server   |<br>    |    Application  |                                         |                                     |<br>    +-----------------+                                         +-------------------------------------+<br>               |                                                            |<br>               |                                                            |<br>               |                                                            |<br>               |        1. Redirect user to authorization server with       |<br>               |           client ID, redirect URI and scope                |<br>               |-----------------------------------------------------------&gt;|<br>               |                                                            |<br>               |                                                            |<br>               |        2. Prompt user to authenticate and grant access     |<br>               |&lt;-----------------------------------------------------------|<br>               |                                                            |<br>               |                                                            |<br>               |        3. Redirect user back to redirect URI with          |<br>               |           authorization code                               |<br>               |&lt;-----------------------------------------------------------|<br>               |                                                            |<br>               |                                                            |<br>               |        4. Exchange authorization code for access token     |<br>               |           using client ID and client secret                |<br>               |----------------------------------------------------------------&gt;|<br>               |                                                            |<br>               |                                                            |<br>               |        5. Respond with access token                        |<br>               |&lt;----------------------------------------------------------------|<br>               |                                                            |<br>               |                                                            |<br>               |        6. Access Google Analytics API using access token   |<br>               |----------------------------------------------------------------&gt;|<br>               |                                                            |<br>               |                                                            |<br>               |        7. Respond with requested data                      |<br>               |&lt;----------------------------------------------------------------|<br>               |                                                            |<br><br>            <br>                            OAuth 2.0 flow for Google Analytics</pre><p><em>Steps :</em></p><ol><li><em>Register your application with the Google API Console and enable the Google Analytics API.</em></li><li><em>Get the client ID and client secret for your application.</em></li><li><em>Get google authorization code to access the user’s Google Analytics data.</em></li><li><em>Authenticate and grant authorization to your application.</em></li><li><em>Get the access token to your application from the authorization server.</em></li><li><em>Access the user’s Google Analytics data using the access token.</em></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*bULGJihM4mVEsFcroPSmdg.png" /></figure><h4><em>Register your application with the Google API Console and enable the Google Analytics API</em></h4><ul><li><em>Go to </em><a href="https://console.developers.google.com/"><em>Google API Console</em></a></li><li><em>Create a new project</em></li><li><em>Go to library section , search for “Google Analytics API” and enable it for your project</em></li></ul><h4><em>Get the client ID and client secret for your application</em></h4><ul><li><em>In the credentials section , Create credentials -&gt; OAuth client ID -&gt; Configure consent screen -&gt; select user type as external or internal as per your need (external preferred) -&gt; enter details and contact info -&gt; add or remove scopes -&gt; select all the scopes mentioned below ( you can filter according to your need)</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yg1t36V-7IpsXVsZcQTG5w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VeenpgQmudqA8ULZDHIyWA.png" /></figure><ul><li><em>add users ( can add your mail id as well)</em></li><li><em>Head back to credentials section as credentials are not yet generated , select web application , give a name , add a redirect uri as “http://localhost” (can add more than one uri)</em></li><li><em>Voila! OAuth client is created and you can store Client ID and Client Secret to use it later for obtaining tokens.</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CLPZZWBcQ3dlSzJHDdjZzw.png" /></figure><h4><em>Get google authorization code to access the user’s Google Analytics data</em></h4><ul><li><em>Paste this url in the browser with your client-id</em></li></ul><pre>https://accounts.google.com/o/oauth2/v2/auth?scope=https://www.googleapis.com/auth/analytics.readonly&amp;access_type=offline&amp;redirect_uri=http://localhost&amp;response_type=code&amp;client_id=&lt;client-id&gt;</pre><ul><li><em>You will get a response of following type with the code = 4%2F0AEtk6oCl6QWsPK54QDTdQ7THDVCS-GPIAIchPqoUnMv5zTxgdwGVG952VX7-j8GWYA</em></li></ul><pre>http://localhost/?code=4%2F0AEtk6oCl6QWsPK54QDTdQ7THDVCS-GPIAIchPqoUnMv5zTxgdwGVG952VX7-j8GWYA&amp;scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fanalytics.readonly</pre><h4><em>Authenticate and grant authorization to your application.</em></h4><ul><li><em>The user is prompted to authenticate with their Google account if they are not already signed in.</em></li><li><em>The user is presented with a consent screen that describes the authorization request, and asked to grant or deny authorization to your application.</em></li><li><em>If the user grants authorization, they are redirected back to your application with an authorization code</em></li></ul><h4><em>Get the access token to your application from the authorization server</em></h4><ul><li><em>Curl request to get access token and refresh token</em></li></ul><pre>curl --location --request POST &#39;https://accounts.google.com/o/oauth2/token&#39; \<br>--header &#39;Content-Type: application/x-www-form-urlencoded&#39; \<br>--header &#39;Cookie: NID=511=HCXdiRL_N5rs_0CoPr0Kq4jJJ4mAwlq21B51AWiv3CpQeloWLV9WKbjoLLnvLfXiwJW-Rn7sGqpp_ECqiisp4dYefNJeh4Pa4qLGZLW0vP_jcNIyr-GP6bdD8oQJ5re4PTcVgNU3UjoiiC5Q_tWfscFNZWXZJRYcVzqA3u2l1A0; __Host-GAPS=1:6dbX2JhkxvNv80uqAtMS_Fpu3H-bVg:LMzll62vE1DyrvS_&#39; \<br>--data-urlencode &#39;code=&lt;authorization-code&gt;&#39; \<br>--data-urlencode &#39;client_id=&lt;client-id&gt;&#39; \<br>--data-urlencode &#39;client_secret=&lt;client-secret&gt;&#39; \<br>--data-urlencode &#39;redirect_uri=http://localhost&#39; \<br>--data-urlencode &#39;grant_type=authorization_code&#39;</pre><p><em>Response type is as follows</em></p><pre>{<br>    &quot;access_token&quot;: &quot;ya29.a0AexVLshlw4_H35o73bSSNQ8YIYzUsKEgYzVx8Mq1fhpk_-t8P73RHwPNGV3J5HuEejggesK_T11tO6BCEdJH2oRdaTQaCgYKAc8SARMSFQF4udJhCuXardhyQ7kDYmmdWNSM4A0165&quot;,<br>    &quot;expires_in&quot;: 3567,<br>    &quot;scope&quot;: &quot;https://www.googleapis.com/auth/analytics.readonly&quot;,<br>    &quot;token_type&quot;: &quot;Bearer&quot;<br>}</pre><h4><em>Access the user’s Google Analytics data using the access token</em></h4><ul><li><em>Include the access token in the Authorization header of API requests to the Google Analytics API, using the format “Bearer ACCESS_TOKEN”.</em></li><li><em>The API responds with the requested data</em></li></ul><ol><li><em>Get metadata</em></li></ol><pre>curl --location --request GET &#39;https://analyticsdata.googleapis.com/v1beta/properties/336644331/metadata&#39; \<br>--header &#39;Authorization: Bearer &lt;access-token&gt;&#39;</pre><p>2. <em>Get account summaries</em></p><pre>curl --location --request GET &#39;https://www.googleapis.com/analytics/v3/management/accountSummaries&#39; \<br>--header &#39;Authorization: Bearer &lt;access-token&gt;&#39;</pre><p><em>3. Get all accounts to which the user has access</em></p><pre>curl --location --request GET &#39;https://www.googleapis.com/analytics/v3/management/accounts&#39; \<br>--header &#39;Authorization: Bearer &lt;access-token&gt;&#39;</pre><blockquote>You can view &amp; fork my Postman collection uploaded here:</blockquote><p><a href="https://www.postman.com/gold-zodiac-140027/workspace/abhiruchi-oauth-postman-collection/collection/20917539-18d41241-f537-4aa4-8f38-2b77be9e076c?action=share&amp;creator=20917539">Google Analytics Authentication | Abhiruchi OAuth Postman Collection</a></p><h4>Troubleshooting (FGE )</h4><blockquote><strong>Redirect uri mismatch </strong>: Verify if redirect uri mentioned in the curl request and added in the application (step 2) is same.</blockquote><blockquote><strong>“error”: “invalid_grant”, “error_description”: “Malformed auth code.” : </strong>Regenerate authorization code (step 3) and try curl request again (step 4) .</blockquote><blockquote>Still getting the error? Retry in a new postman session.</blockquote><blockquote><strong>Refresh token not generated as a response for step 5 : </strong>Refresh token will be generated only once on first authorization from the user.Subsequent authorizations, such as the kind you make while testing an OAuth2 integration, will not return the refresh token.</blockquote><blockquote><strong>Hack</strong> : Go to the page showing Apps with access to your account — <a href="https://myaccount.google.com/u/0/permissions">https://myaccount.google.com/u/0/permissions</a>. Under the Third-party apps menu, choose your app.Click Remove access and then click Ok to confirm.The next OAuth2 request you make will return a refresh token</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d0d121a68259" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>