<?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 Julio Ayala on Medium]]></title>
        <description><![CDATA[Stories by Julio Ayala on Medium]]></description>
        <link>https://medium.com/@julioayala111?source=rss-612e61b0f327------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*RtAhVkE3LoC9qG-x</url>
            <title>Stories by Julio Ayala on Medium</title>
            <link>https://medium.com/@julioayala111?source=rss-612e61b0f327------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 11:01:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@julioayala111/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[Use Google Calendar through a Service Account from a PHP aplication]]></title>
            <link>https://medium.com/@julioayala111/use-google-calendar-through-a-service-account-from-a-php-aplication-51a24a81230d?source=rss-612e61b0f327------2</link>
            <guid isPermaLink="false">https://medium.com/p/51a24a81230d</guid>
            <category><![CDATA[domain-wide-delegation]]></category>
            <category><![CDATA[google]]></category>
            <category><![CDATA[gcp]]></category>
            <category><![CDATA[google-calendar]]></category>
            <dc:creator><![CDATA[Julio Ayala]]></dc:creator>
            <pubDate>Fri, 29 Oct 2021 04:39:49 GMT</pubDate>
            <atom:updated>2021-10-29T04:39:49.493Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DXK9AfOaLcJt5w87wK5NTA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@brett_jordan?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Brett Jordan</a> on <a href="https://unsplash.com/s/photos/google-calendar?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Recently I need to integrate the Google Calendar Api for a client dating app, my first impression was “ah ok, its another API more”, even I gave an overly optimistic estimate. It was a hard way… There are many tutorials about that but, I need to discover some things that I want to share.</p><blockquote><strong><em>The things that you need to know</em></strong></blockquote><h4><strong>1. You need a Google Workspace licence to be able to create events in Google Calendar from a service account</strong></h4><p>Unfortunately I knew this very late when the project had started to run. The thing is, there are two ways for Authenticate and Authorize an aplication for manage the Google Calendar. The first <a href="https://developers.google.com/calendar/api/quickstart/php"><strong>using OAuth 2.0 for Web Server Applications</strong></a><strong> </strong>that is a easy way, but, what if the person who give the access leave the organization?, in my case I needed to create events on behalf of the organization, and ansure that the aplication will be able to create events even if any person leave the organization, so this brings us to the next point…</p><p><em>You can read events from the Google Calendar of a Free Gmail Acount, and create events using OAuth 2.0 authentication but you can’t create events by a service account to a free Google Acount</em></p><h4>2. You need access to the Google Workspace Console to set up Domain Wide Delegation</h4><p>To impersonate a domain user you need access to Google Workspace Console, it works something like that: <a href="https://developers.google.com/admin-sdk/directory/v1/guides/delegation"><strong>setting up a service accout in the Google Workspace Console</strong></a> can impersonate a person and manage all the Google Calendar resources like a Google Workspace user can do.</p><h4>3. You need access to Google Cloud Console to create a service account and set up Domain Wide Delegation too</h4><p>You need to create a service account and mark the checkbox for enable Domain Wide Delegation, this will allow you to act as a person from the application used a service account.</p><h4>4. You need to run a short code to insert a caledar to the service account</h4><p>Since a service account is not a Google Workspace User it can’t receive emails and it can’t accept an invitation to colaborate in a Google Calendar, for that, we need to run a short code to insert the calendar to the service account let it manage, and then create and read events.</p><blockquote><strong><em>The steps to able the access from a Service Account to Google Calendar</em></strong></blockquote><h3>1.- Create the service account</h3><ul><li>Create the service account with <strong>Service Account Token Creator </strong>permission, make and download de json key witch will need later.</li><li>Write down the service account email for later.</li></ul><h3>2.- Make sure the Google calendar API is enabled</h3><p>Go to <strong>APIs &amp; Services &gt; Enable APIs &amp; Services &gt;</strong> find for <strong>Google Calendar API </strong>and make sure that it´s enable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/0*ulesN5B9qaU2-Lb3" /></figure><h3>3.- Enable G Suite Domain-wide Delegation in GCP</h3><p>Go to<strong> IAM &amp; Admin &gt; Service Accounts</strong> in your Google Developer Console. Click the three dots on the service account name you’re using and click on Edit. <strong>You need to enable G Suite Domain-wide Delegation.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5QE5LVFNk_4y7w9C" /></figure><h4><strong>Get de unique_id to setup in google workspace console later.</strong></h4><h3>4.- Share a the Google Calendar with the service account</h3><p>1.- Go to the <strong>Google Calendar Application &gt; configuration</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iSkBkH74JxNSZgdE" /></figure><p>2.- Selecciona el calendario que quieras compartir con la app</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/0*2uIOWPFxlWjbhF6C" /></figure><p>3.- Scroll Down until “Shae with specific people…” and click on “Add people”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/1*icODqhXqjG0uTPQXlM3zsg.png" /></figure><p>4.- Add the service account email and give it the necessary permissions.</p><p>In my case ¨Make changes to events¨ was necessary to create new events.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*nKdql3T8iW84RtlZKCMscA.png" /></figure><h3>5.- Get the Calendar ID</h3><p>In the same page do scroll down until “Integrate calendar” and copy the Calendar Id for later.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*-1dXMfdccfa-uczoTD3qJw.png" /></figure><h3>6.- Install Google Client Library</h3><p>In the project install the next dependency :</p><p><strong>composer require google/apiclient</strong></p><h3>7.- Insert the calendar to the service account</h3><p>As I mentioned at the beginning, it <strong>is necessary to insert the calendar</strong> into the service account, since it is not a user, it cannot accept the invitation to the calendar by a click. We need to insert the calendar through a short code.</p><pre>$client = new Google_Client();</pre><pre>$client-&gt;setScopes(Google_Service_Calendar::<em>CALENDAR</em>); $client-&gt;setAuthConfig(‘SERVICE ACCOUNT PATH’);</pre><pre>$service = new Google_Service_Calendar($client);</pre><pre>$calendarListEntry = new Google_Service_Calendar_CalendarListEntry();</pre><pre>$calendarListEntry-&gt;setId(“ID_CALENDARIO”);</pre><pre>$createdCalendarListEntry = $service-&gt;calendarList-&gt;insert($calendarListEntry);</pre><pre>echo $createdCalendarListEntry-&gt;getSummary();</pre><h3>7.- Enable Domain Wide Delegation in Google Workspace Console</h3><p>Documentation here: <a href="https://developers.google.com/admin-sdk/directory/v1/guides/delegation">https://developers.google.com/admin-sdk/directory/v1/guides/delegation</a></p><ol><li>From your Google Workspace domain’s <a href="http://admin.google.com/">Admin console</a>, go to <strong>Main menu</strong> menu<strong>&gt; Security &gt; API controls</strong>.</li><li>In the <strong>Domain wide delegation</strong> pane, select <strong>Manage Domain Wide Delegation</strong>.</li><li>Click <strong>Add new</strong>.</li><li>In the <strong>Client ID</strong> field, enter the client ID obtained from the service account creation steps above (<strong>THE CLIENT ID, NOT THE SERVICE ACCOUNT EMAIL</strong>).</li><li>In the <strong>OAuth Scopes</strong> field, enter a comma-delimited list of the scopes required for your application, in my case for create events:</li></ol><ul><li><a href="https://www.googleapis.com/auth/calendar">https://www.googleapis.com/auth/calendar</a></li><li><a href="https://www.googleapis.com/auth/admin.directory.resource.calendar">https://www.googleapis.com/auth/admin.directory.resource.calendar</a></li><li><a href="https://www.googleapis.com/auth/calendar.events">https://www.googleapis.com/auth/calendar.events</a></li></ul><h3>8.- Allow sharing of secondary calendars</h3><p>You’ll need to log in to your<a href="https://admin.google.com/"> Google Admin</a> account and then go to Apps &gt; Calendar. Go to General Settings, and allow managing of calendars.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oQY8ttcvjSZLcSmG" /></figure><p>You may want to do the same for Primary calendars as well under Sharing Settings.</p><h3>7.- Get a calendar</h3><p>To make sure that it is possible to retrieve the calendar data from the service account, we can create a code like the following:</p><pre>$client = new Google_Client();</pre><pre>$client-&gt;setScopes(Google_Service_Calendar::<em>CALENDAR</em>);<br>$client-&gt;setAuthConfig(‘SERVICE ACCOUNT PATH’);</pre><pre>$service = new Google_Service_Calendar($client);</pre><pre>var_dump($service-&gt;calendarList-&gt;get(‘CALENDAR_ID’));</pre><h3>9.- Impersonate a domain user</h3><p>In order to be able to create events in a user’s calendar, it is necessary to impersonate a user within the domain using the service account</p><p>Below I share a code to authenticate from the service account with Google Calendar:</p><pre>$client = new Google_Client();</pre><pre>$client-&gt;setScopes([Google_Service_Calendar::<em>CALENDAR</em>]);</pre><pre>$client-&gt;setAuthConfig(credential(env(‘SERVICE ACCOUNT PATH’)));</pre><pre>$client-&gt;setSubject(ejemplo@dominio.com’);</pre><blockquote><strong>Thanks for reading</strong></blockquote><p>If you want to contribute to my work and support me to continue writing more blogs of this type please follow me and applaud this story.</p><blockquote><strong><em>References</em></strong></blockquote><p><a href="https://developers.google.com/calendar/v3/reference">https://developers.google.com/calendar/v3/reference</a></p><p><a href="https://developers.google.com/calendar/quickstart/php">https://developers.google.com/calendar/quickstart/php</a></p><p>https://developers.google.com/admin-sdk/directory/v1/guides/delegation</p><p><a href="https://developers.google.com/identity/protocols/oauth2/service-account#authorizingrequests">https://developers.google.com/identity/protocols/oauth2/service-account#authorizingrequests</a></p><p><a href="https://neal.codes/blog/google-calendar-api-on-g-suite/">https://neal.codes/blog/google-calendar-api-on-g-suite/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=51a24a81230d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why do companies need to move to the public cloud?]]></title>
            <link>https://medium.com/@julioayala111/why-do-companies-need-to-move-to-the-public-cloud-9efe80e90d1a?source=rss-612e61b0f327------2</link>
            <guid isPermaLink="false">https://medium.com/p/9efe80e90d1a</guid>
            <category><![CDATA[agile-development]]></category>
            <category><![CDATA[public-cloud]]></category>
            <category><![CDATA[business-strategy]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <dc:creator><![CDATA[Julio Ayala]]></dc:creator>
            <pubDate>Mon, 18 Oct 2021 19:38:40 GMT</pubDate>
            <atom:updated>2021-10-18T19:38:40.299Z</atom:updated>
            <content:encoded><![CDATA[<p>This is my first post, I will share business and technical topics. follow me to more content.</p><h3>The origin</h3><p>Since the internet was invented in 1960 the people who are responsible for managing the infrastructure have found many challenges about how well the resources are managed and connected. Google started their company with 20 machines and 2 routers HP in 1998 only one year later Google ran the principal service (google search) in 112 machines, and the most interesting at this moment… <a href="https://www.datacenterknowledge.com/archives/2014/07/23/from-112-servers-to-5b-spent-on-google-data-centers-per-quarter">Google makes the largest server order</a>; 1,680 servers. We can only imagine the amount of people needed to manage this infrastructure. It’s true that Google was a unicorn, but the challenges for managing infrastructure all the time were there. The TI teams used to manage their own servers in VMs, DBs, DevOps process, etc, but the habits and things that we do have changed over time.</p><h3>SMB Companies</h3><p>What happens if you have a great idea? What happens if you have a SMB company, and you want to host some service? Maybe, the traditional companies can start buying or renting some servers, hiring some Sys Admins, some DBAs, DevOps, Developers, etc. maybe you have a limited budget. What if your business grows a lot that you need more people and more infrastructure? What kind of investment do you need to do?</p><p>On the other hand, imagine that you have a great business idea, but commonly you don’t have a lot of money, consider one thing; <a href="https://www.embroker.com/blog/startup-statistics/">In 2018, there were 30.2 million small businesses operating only in the U.S.</a> You should develop your idea before someone does it for you.</p><p>Currently one of the most difficult challenges is the competitors, there are many other companies developing more skilfully, with more budget with more hands to do the work.</p><p>Let me share with you some advices.</p><p>Today, you don’t need to rent a lot of resources to host your service, you don’t need to hire Sys Admins, DBAs, DevOps, etc. (Not yet). You can focus only on developing the idea and paying the bills that you consume. You can develop and host an MVP (Minimum Viable Product) and expose it to your users in less time than a few years ago. You can expose, test, and get feedback from the real users. You can worry about the growth of your service later.</p><p>Why the Public Cloud? The public cloud lets you use the lasted technology and get resources as you need. You can use full managed services and your people can only focus on the development, you pay only what you use, or you reserve.</p><p>Why full managed services? The cloud vendor improves these services all the time which worries about the patch, updates, and infrastructure. You can only use it and do not worry for the management under the hood.</p><p>What about the storage? You should use fully-managed services and then focus on the applications or services developed, even if you want to take control of your own storage services you can host on the cloud and use all the resources as you can use or pay.</p><p>The public cloud is the key for many of our challenges. The public cloud lets us take advantage of the power of services to agile our deliveries and take advantage of the competition. You can use global resources to serve services across the world and pay only what we use. In many cases you don’t need to allocate resources that we aren’t sure if we will use. We can even improve our costs using the ability to scale the resources in the cloud enabling the ability to scale up when we have traffic spikes and scale down when the services are not used. On the other hand, we can save money using fully-managed services and leaving aside a lot of tasks like patch, updates, deployments, etc. Notice that you will need to hire some specialist in the cloud, and in the future maybe you will need to hire people to improve your business, but you can start using fully-managed services and later migrate to a robust infrastructure.</p><h3>Large enterprise</h3><p>What if you have an infrastructure, and people already? What if you have a big company and you need to take advantage of your competitors? What if you need to improve your business?</p><p>You should start to migrate to the cloud, these let you improve the service in all ways. You can take advantage of the resilient, fast, and reliable infrastructure of Public Cloud, you can take advantage of the capacity of automation.</p><p>Consider the next use case:</p><p>Your business has an application dedicated to clothes selling which collects data from their users to big data, you want to improve your business through ML Models to recognise clothes for sale to a specific user. You can be tempted to get a big budget and hire a big team to solve the challenge, but you should consider using a cloud built-in service to solve the challenge, since the built-in services can support many use cases, you should start to search if some service adapts to your requirements.</p><p>Public cloud offers the tools needed to automate your development process and free up time</p><p>that you can use to improve your business. Using the diversity of services you can make the work better.</p><p>Finally, you can take advantage of the capacity of the cloud to host services in the most important places for you clients, using goodness like reliability, alanticity and the most important security.</p><h3>What does the future hold?</h3><p>The mayor of the companies started to move to the cloud. Big Companies like Paypal, Walmart, Home Depot, BBVA are already in the cloud.</p><p>You should start to migrate to the cloud and get the benefits for your business.</p><p>Whatever it is, the companies will make more powerful applications every time with fewer people, and we will use fully-managed services to solve most of our challenges.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9efe80e90d1a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>