Start Here !

Welcome to my website. Find articles, presentations, tutorials, experiments on various technologies. Drop me a line in case you want me to cover something specific.

Read On:

You can get in touch with me anytime at

r o m i n . i r a n i @ m i n d s t o r m s o f t w a r e . c o m

I am also active on Twitter – do follow me.

Posted in Uncategorized | Leave a comment

My articles @ProgrammableWeb : January – March 2014

Here is the list of my articles published @ProgrammableWeb in the period : January – March 2014:

Posted in Personal, Publications | Leave a comment

Speaking Engagements in March 2014

March has been a great month for interacting with various Google Developer Groups across the country. I was privileged to speak at 3 key events organized by GDG Groups in Cochin, Ahmedabad and Mumbai.

Last month (Feb), I spoke at the Dart Flight School event in Mumbai. And this month, we went a step further with both an “Introduction to Dart” and “Dart Code Lab” that was held in GDG Cochin. For more info, refer to my blog post.

Dart Flight School   Learn Dart

The next event was in GDG Ahmedabad and this time it was one of the many Women TechMakers events that have been held across the world. I spoke on “Overview of the Google Cloud Platform”. The organizers were gracious to give me a big timeslot that enabled me to cover parts of Google Compute Engine, App Engine and Google APIs. The purpose of my talk was to demonstrate that if you have an idea today and are passionate to convert the idea -> application, the cloud can be a great enabler, especially with the great set of infrastructure and tools that Google Compute Platform provides. For more info, refer to my blog post.

Google Developers

The last event for the month was held in Mumbai and once again it was the Women TechMakers edition that was organized by GDG Mumbai. I gave an overview of the Google Cloud Platform here too.

Home — Google Cloud Platform

Overall, a big thank you to Google India Developer Relations Team (Uttam & Shrey) for giving me the opportunities, respective GDG Organizers for inviting me to speak at their events and the enthusiastic community with which I can interact, share my experience and learn from.

Posted in Personal | Leave a comment

Women TechMakers Event – GDG Ahmedabad

I was privileged to be invited to speak at Women Technmakers Event, organized by GDG Ahmedabad on March 22, 2014.

Women TechMakers is an initiative by Google to ensure that there is visibility, community and resources available for women in technology. I believe that women have played a significant role in technology and it is important that in our industry, the percentage of women increases. It is going to benefit everyone.

The event in GDG Ahmedabad was a mix of technology and business. The event also highlighted women entrepreneurs who have excelled in the technology industry. Given that some of them were not technical to start with, but still persisted with their idea and passion to see that happen, is ample proof of what can be achieved. I personally believe that there is no difference between men and women. And to a certain extent I think holding events like these are important and I will be very glad if there will be no need to hold events like this in the future. It is up to each one of us to make that a reality.

The GDG Ahmedabad Event was held at Pride Hotel in Ahmedabad. I love the GDG Ahmedabad Team with Paresh Mayani, GDG Ahmedabad Head, a pleasure to work with. This was my 2nd visit to GDG Ahmedabad, having conducted a workshop last year on Google App Engine.

The event was kicked off by Rama Moondra, who gave an inspiring talk on “Women and Equal Opportunities”.

My talk at the event was about 90 minutes and I highlighted how the Cloud can help everyone spiral their ideas from inception to both economical and scalable implementation, which is also cost effective. My examples were that of Google Cloud Platform and Google App Engine, both of which I demonstrated. I was happy to demo spinning a VM on Google Compute Engine, install Apache, modify a page and show them a live site in under 5 minutes (network latency included! :-))

IMG_2955

We saw informative sessions following mine with real and successful models that Women Entrepreneurs like Ilaxi Patel, Ruzan Khambatta and Sneha Thakker have implemented. The talks were a mix of business and technology and the afternoon session saw talks on Project Management, Apponamics and more.

Check out the photos from the event 

Overall, it is a satisfying trip to Ahmedabad to interact once again with the GDG audience. I personally believe this chapter of GDG has some of the highest energy levels with a real zeal to learn and make the best of networking opportunity. I hope to be back again.

 

 

Posted in Personal | 1 Comment

Dart Flight School – GDG Cochin

I had the privilege of conducting Dart Flight School in Cochin on March 9, 2014. It was also the first anniversary of GDG Cochin and it is wonderful to learn about the activities that they had conducted over the last year and be part of their 1st anniversary celebration.

IMG-20140310-WA0015

We started off with Dart Language Basics and then the entire Dart Ecosystem with its tools. We took a look at several Dart language example code and then broke for lunch. Post lunch, we took off with the Dart Code Lab (Pirates Ahoy!). There were several goodies to be won for not just completing the Dart Code Lab but also for trying out something different, modifying the Dart Code Lab example and more. We saw a few attempts that took the Dart Code Lab code further.

Take a look at happy Dartisans at the end of the event:

1558408_279422732215889_613478823_n (1)

A big thank you to all members of GDG Cochin with special thanks to Sanjay Nediyara  and Rahul Ramesh (GDG Cochin – Organizers) for superb management of the event.

Posted in Personal | 1 Comment

Speaking Engagements – Feb 2014

February was a good month for interacting with developers across Mumbai. I was privileged to speak on a variety of topics across 3 sessions in February to over 250+ Developers in total.

The sessions were:

This was a marquee event held in Mumbai as part of the February campaign by Google to promote the Dart Language. I have enjoyed learning this language that makes the life of a Web Developer easier and love the language for its syntax. I was privileged to take the opening session on “Introduction to Dart” at the GDG Mumbai Flight School Event. There were between 160-200 people for the event and hope that some of them go back with an interest to learn more about Dart.

My Opening Session on Dart Language

The highlight for all of us at the event was an appearance by Kasper Lund, co-creator of Dart, who shared his insights on the language and took on Q&A from the event attendees.

Kasper Lund during his hangout

  • Rubix 2014 – Android & HTML 5 Workshops

I conducted a couple of developer workshops during Rubix 2014. Both the workshops were about 3 hours duration and introduced folks to Android Development and HTML5 APIs respectively.

Working with Developers is always a joy and especially when you introduce them to new stuff and see them taking those first steps to what these technologies / frameworks / languages help bring to the table.

I have an upcoming trip to GDG Cochin on March 9, 2014 to speak in their Dart Flight School Event. I look forward to that.

Posted in Personal | 4 Comments

Google Cloud Endpoints Tutorial – Part 7

Welcome to Part 7 of the Google Cloud Endpoints Tutorial.

The series so for:

  • Part 1 : We looked at writing a Google Cloud Endpoints class manually by using the various annotations and Exception classes that are available. We create a Quotes API that provided a JSON + REST based interface to manage Quotes (add, modify, delete and retrieve quotes).
  • Part 2 : We generated the Google Cloud Endpoints class from a JDO Annotated Entity class by using the Code Generation tools provided in the library.
  • Part 3 : Generated the Cloud Endpoints Client Library for Android and wrote an Android application that invokes the Endpoints API.
  • Part 4: We wrote a JavaScript client for our Endpoints API.
  • Part 5: Securing our API
  • Part 6: Calling a Secured API from a JavaScript client.

In this episode

So far in this series, we looked at writing a Quote API and in the last couple of episodes, we introduced how to secure your API methods so that only authorized clients can invoke the methods and we demonstrated how to make secure calls from our JavaScript client.

What do you need ?

  • You have a working development environment for Google App Engine. This includes the Google Eclipse plugin.
  • The API Project 2 (Quotes Endpoint Project) loaded in your Development Environment. This is the same as the previous episode.
  • You have a working development environment for Android. I have used Eclipse with the ADT Plug-in.
  • Basic understanding of Android Application Development. We will be using the same code that we had used in Part 3 : Writing an Android client.

My Development Environment

  • This remains the same, no changes at all. My development environment is given below:
    • Eclipse Juno
    • Google Eclipse plugin with App Engine SDK 1.8.8
    • Android ADT Plugin with latest Android SDK installed.
    • Mac + Windows machine (I kept switching from one to another, to keep everyone happy ;-))

Invoking the Secure API from Android client

In the last post, we had demonstrated how to make a secured call to the insertQuote method from a JavaScript client. In the Android version of that in this episode, we will be using the same code as we have used in Part 3, except that in the Add Quote Activity, we shall be modifying our code to make secured calls from the Android native application.

Let us first revisit the whole thing about Web Client Id and Audiences that we had setup for our Quotes API earlier.

Web Client Id

If you recollect, in the earlier episode, we had visit the Google Cloud Console for our project and create the OAuth Client Id. A screenshot of the Web Client Id is shown below.

Screen Shot 2014-02-14 at 8.45.01 PM

We created a Constants.java file that contained all these IDs as given below:

Notice that the ANDROID_AUDIENCE is what we are going to use here and it has been set to the same value as the WEB_CLIENT_ID.

Additionally, we had updated the @APIMethod for insertQuote and provided the clientIds, that included the Web Client Id and then deployed the API.

Again notice that we have specified the Client Ids that can access the insertQuote method and also mentioned the ANDROID_AUDIENCE in the audiences attribute.

Remember to regenerate your Client Libraries, just in case you have not done so and deploy it as needed. 

Famous Quotes Android Application Code

We are going to use the same code base as the original Famous Quotes Android application that was covered in Part 3I strongly suggest to go through that first to ensure that you have your Android application and all dependencies set up correctly.

If you want to download that source code, it is available here.

Play Services SDK

Since we are going to make an authenticated call from the Android client, the process will be that we will use the currently logged in Google Account on your Android device. Since this requires Account Picker and other classes on Android from the Play Services Library, it is required that you download the correct Play Services SDK and set that up as a library in the application.

Make sure you link up to the correct library depending on the version that you want to target. I tried out my code on a Android 2.3 device too and it bombed with the latest version of the Play Services SDK. As a result of which, I had to link up to a Froyo version of the library.

So, the first thing to do is to ensure that you have the Play Services SDK. For e.g. in the Android SDK Manager, you can see it over here:

cep7-1

Once you install (download) the above packages, they will be available in the ADT Folder\sdk\extras\google folder as given below:

cep7-2

Simply go to your Eclipse environment and Import any of the above projects as applicable. These are Android library projects and make sure you are able to import it successfully. 

Next, simply add the Play Services library project to your Famous Quotes Android application. The Properties page with the library linked up successfully is shown below:

cep7-3

This completes the development environment setup.

Let us look at the parts of the Add Quote Activity that we modified to ensure that the correct credentials are passed over behind the scenes while making the secure calls from the Android client.

AddQuote Activity Source Code

The entire source code for the AddQuote Activity is shown below:

Let us focus on the important parts and how the Account Credentials are setup before invoking the Secure Cloud Endpoints API.

  • Pay attention first to the onCreate(…) method. The code is identical to the earlier one where we setup the onclick listener for the AddQuote button.
  • There is a section starting with the comment //Account Stuff and there we create an instance of the GoogleAccountCredential class. We create that using the usingAudience method. Notice that the Audience Id string has to be created as follows “server:client_id:<AudienceId>
  • Once the GoogleAccountCredential instance is setup, we invoke the setAccountName method. This method uses Android SharedPreferences , to determine if an ACCOUNT_NAME String preference value was set. If yes, we set that account name for the GoogleAccountCredential instance.
  • We check in the next line if the name has been selected, if not – we invoke the chooseAccount() method, that starts the standard Account Picker activity on your Android phone. This will allow you either login or choose from one or more of your accounts on the device. Once selected, we invoke the setAccountName() method again to set the account name in the GoogleAccountCredential instance and set the value in the SharedPreferences too.
  • Now that the the GoogleAccountCredential is all set, the other change you will notice is in the AddQuoteAsyncTask.
  • In the doInBackground method, notice the following line:
    Quoteendpoint.Builder builder = new Quoteendpoint.Builder(
                    AndroidHttp.newCompatibleTransport(),
                    new GsonFactory(),
                    credential);

    Here, we are no longer passing null in the 3rd parameter. We are using the GoogleAccountCredential instance.

AndroidManifest.xml Permissions

We need to add some additional permissions to the AndroidManifest.xml file as given below:

Project Source Code – Download

The source code for the MyAPIProject2 is available in Github. You can download the entire source code over here.

Additionally, the source code for the secure FamousQuotes Android application is also provided over here.

This brings to an end, the series on Cloud Endpoints as I had originally planned out. Hope you liked the series so far. Give me feedback to help me create more and better content.

I do hope to blog about comparing Google Cloud Endpoints with other methods of writing Web Services along with some stuff that I would ideally like the next release of Google Cloud Endpoints to address both in features, samples and documentation.

Posted in Cloud Computing, Google App Engine | 2 Comments

Google Cloud Endpoints Tutorial – Part 6

Welcome to Part 6 of the Google Cloud Endpoints Tutorial.

The series so for:

  • Part 1 : We looked at writing a Google Cloud Endpoints class manually by using the various annotations and Exception classes that are available. We create a Quotes API that provided a JSON + REST based interface to manage Quotes (add, modify, delete and retrieve quotes).
  • Part 2 : We generated the Google Cloud Endpoints class from a JDO Annotated Entity class by using the Code Generation tools provided in the library.
  • Part 3 : Generated the Cloud Endpoints Client Library for Android and wrote an Android application that invokes the Endpoints API.
  • Part 4: We wrote a JavaScript client for our Endpoints API.
  • Part 5: Securing our API

In this episode

So far in this series, we looked at writing a Quote API and in the last episode, we introduced how to secure your API methods so that only authorized clients can invoke the methods. We secured the insertQuote method in the last episode and in this episode, we are going to see how to make secure calls from our JavaScript client.

Keep in mind that we had written a JavaScript client for our Endpoints API earlier in Episode 4, so please take a look at that first.

What do you need ?

  • You have a working development environment for Google App Engine. This includes the Google Eclipse plugin.
  • The API Project 2 (Quotes Endpoint Project) loaded in your Development Environment. This is the same as the previous episode, except that we will be focusing on the apitest.html , which is our API client.

My Development Environment

This remains the same, no changes at all. My development environment is given below:

  • Eclipse Juno
  • Google Eclipse plugin with App Engine SDK 1.8.8.
  • Mac + Windows machine (I kept switching from one to another, to keep everyone happy ;-))

Web Client in Action

Let us first try to understand what we are going to create here by seeing the application and security in action.

I am accessing the client at http://mybackendapi.appspot.com/apitest.html. I have currently logged out from all of my Google Accounts.

When I access the above page, I get the following page:

Screen Shot 2014-02-15 at 2.45.24 PM

Notice the Login button shown above. This button is shown if there was no Google Account that was already logged in. If the User was logged in, this button would be invisible and instead we would be having a Welcome message.

Now, we will not yet click on the Login button. Instead we will attempt to insert a new Quote without logging in and verify if the insertQuote method is indeed secured or not. We enter test values in the Author Name and Quote as shown below and click on the Insert Quote button. This will bring up a popup as shown below. In fact this is the response that we have simply displayed and which came from the Endpoints API HTTP Response:

Screen Shot 2014-02-15 at 2.45.46 PM

In the JavaScript code, I log out the response to the console and which you can see below:

Screen Shot 2014-02-15 at 2.45.57 PM

Now, I click on Login and go through the standard OAuth dance, where I choose a Google Account to log in with, give my credentials and then authorize the application. If all is well, I am logged into our client now and we retrieve the User Name from the OAuth API and display a welcome sign on the top, as shown below:

Screen Shot 2014-02-15 at 2.43.57 PM

Now, I can give my sample values for the Author Name and Quote and click on Insert Quote. 

Screen Shot 2014-02-15 at 2.44.37 PM

The record will get inserted and when I do a List Quotes , I will see the new record that I added:Screen Shot 2014-02-15 at 2.44.57 PM

Let us discuss the code now.

Web Client Id

If you recollect, in the earlier episode, we had visit the Google Cloud Console for our project and create the OAuth Client Id. A screenshot of the Web Client Id is shown below.

Screen Shot 2014-02-14 at 8.45.01 PM

Additionally, we had updated the @APIMethod for insertQuote and provided the clientIds, that included the Web Client Id and then deployed the API. 

JavaScript Client

The entire source code for apitest.html is shown below. The code snippets for Login functionality has been borrowed from the sample code provided in the official document by Google.

Let us look at the main points. Parts of the code should be familiar if you have worked with the JavaScript client that was introduced in Part 4 of this series.

  • We have added a Login button to the User Interface.
    <div id=”login”>
    <input id=”loginButton” type=”button” value=”Login”/>
    </div>
  • As covered in an earlier episode, we load the Client API and once the API is loaded, our init method is invoked.
  • In our init method, we are loading two APIs now : the Quote Endpoint API as we have done earlier and the OAuth API.
  • Once both the APIs are successfully loaded, we are invoking the signin method. To the signin method, we are providing two parameters : an immediate mode parameter whose value is set to true and a callback function : handleAuth.
  • In the signin method, we invoke the gapi.auth.authorize method. To that method, we pass the client Id, scope, immediate mode and the callback (handleAuth). Notice that we have initialized the client Id and scope values in the code and they are the same values as the ones we have created via the Google Cloud Console OAuth New Client creation page. These must match for the authentication/authorization to succeed.
  • In the handleAuth method, we get the current User Object. If the User is found with no errors, then we hide the Login button and display the Welcome message. If the User is not found, the Login button is made visible. This is what happens when our page is loaded i.e. Login button is shown or not shown depending on whether the user is logged in or not. This is also known as the immediate mode.
  • Now, if the Login button is shown i.e. authorization still has to be done, then we have a handler for our Login Button as shown below:
    document.getElementById(‘loginButton’).onclick = function() {
             signin(false,handleAuth);
     }
  • If Login Button is clicked, the signin method is called again with the immediate mode set to false and the callback method as the same one i.e. handleAuth. This will invoke the entire Google Login popup and you go through with the Authentication and Authorization cycle.
  • The insertQuote method is slightly modified to display the error in case there is a problem executing the gapi.client.quoteendpoint.insertQuote method.

Project Source Code

The source code for the MyAPIProject2 is available in Github. You can download the entire source code over here.

Hope you liked this episode of the Google Cloud Endpoints tutorial. The next episode will cover making secured API calls from an Android client.

Posted in Cloud Computing, Google App Engine | Tagged | 13 Comments