The KDE’s Summer of Achievements

KDE took part in its 7th year as a mentoring organization for the Google Summer of Code. Thanks to Google’s generous funding and KDE’s mentors we were able to work with 51 students over the summer, once again making KDE the largest organization taking part in Google Summer of Code. Choosing the right students was hard but the selection turned out well. The students coded in nearly all areas of KDE from Calligra and Rekonq to Amarok and KStars. Their projects turned out very well, and we’ve once again been impressed with the talent and dedication of the students. All 51 students passed their mid-term evaluation and 47 successfully passed their final evaluation. Valorie Zimmerman, KDE Administrator for Google Summer of Code, says: “KDE got forty-seven completed projects, which is tremendous. Our focus though is not on the code itself, but on the students and their involvement with KDE. However, their projects enrich KDE immensely, and you’ll be seeing their code integrated into our codebase over the next few months. “
Similar to previous years, KDE received many more great student applications for Google Summer of Code than we were able to accept into the program. To welcome these remaining students to our community and to give them mentoring, support, and a project to work on, we ran Season of KDE again. It is a program similar to Google Summer of Code where students receive a certificate and limited-edition t-shirt for completing their project successfully. The response was overwhelming this year and we had to close applications after 100 submissions. Nearly all of them were matched up with a mentor and project to work on. The students still have a few more weeks to work on their projects but results are looking fantastic so far.
Lydia Pintscher, KDE Administrator for Google Summer of Code and Season of KDE, says: “What makes me proud about this is the fact that KDE as a community is able and willing to teach newcomers to Free Software on a scale like few other projects while delivering high-quality results in terms of code produced and students mentored. What makes me even more proud is the overwhelming success of Season of KDE even without the monetary incentive but just because people want to work on something amazing in an amazing community.”
For more information on each student’s proposal and their blogs about the project can be found on our Status Reports page. We have also posted blogs on our Google Summer of Code Achievements: chapter one, chapter two, and chapter three.

Google Maps – Ads EVERYWHERE

As the jokes were flying about how distasteful Google’s new Map’s info ad venue was, I became curious as to exactly how unseemly it really was. So I looked.

As Glen Gabe pointed out it may very well be necessary for SMB’s to take out ads defensively. Greg Sterling suggested that Google think about a Pandora like subscription so you could search ad free. For me, Google’s ads on the Map info bubble reminds me of ads on “park benches” that sit amid the fumes on street corners.

Here is a slide show that I assembled in 5 minutes to explore the possibilities. Bing is advertising on Zuccotti Park, Bank of America of course advertising on themselves, Chase is advertising on the Lexington Ave  women’s shelter and CPRProfessor advertising on the American Red Cross…. wow. You can click to see a slide show of some of these ads:

OAuth 2.0 for native applications

Following our previous post on OAuth 2.0 for web applications, we are now taking a look at how to use the OAuth 2.0 authentication protocol for native applications, presenting examples for the languages that we are supporting at the moment of writing: Java and Python.
Background

We strongly recommend reading Using OAuth 2.0 to Access Google APIs to learn about the Google implementations of OAuth 2.0 before proceeding with this post.
Java

The Google APIs Client Library for Java features a powerful and easy to use OAuth 2.0 library. We can take advantage of the existing GoogleOAuth2ThreeLeggedFlow helper class to easily perform our authentication flow.

First create an instance of GoogleOAuth2ThreeLeggedFlow, passing the following parameters to the constructor:

  • a key that will be used to associate this flow object with an end user
  • the Client ID for your application
  • the Client Secret for your application
  • the scope you are requesting access to (AdSense in your case)
  • the URI to redirect to
GoogleOAuth2ThreeLeggedFlow authFlow = new GoogleOAuth2ThreeLeggedFlow(
  userId, 
  "INSERT_CLIENT_ID_HERE", 
  "INSERT_CLIENT_SECRET_HERE", 
  "https://www.googleapis.com/auth/adsense", 
  "urn:ietf:wg:oauth:2.0:oob");

For native applications, we use a special redirect URI:

"urn:ietf:wg:oauth:2.0:oob"

The “oob” part stands for “out of band” and the rest of the string identifies it as a part of the OAuth 2.0 standard.

When we use this redirect URI, instead of redirecting the user’s browser to a page on our site with an authorization code, Google will display a page and the authorization code or error response in the title of the page. A text field contained in the page will show instructions for the user to copy and paste it into our application.

To start the flow, let’s ask the user to load the authorization URL in their browser:

System.out.println(“Please input authorization code: ”);
Scanner in = new Scanner(System.in);
String authorizationCode = in.nextLine();

The last step is to use the authorization code to obtain an access token.

First you’ll need to initialize a transport for communication with the Authorization server and a factory for handling JSON, as the access token will be returned as a JSON object:

JsonFactory factory = new JacksonFactory();
HttpTransport transport = new NetHttpTransport();
authFlow.setHttpTransport(transport);
authFlow.setJsonFactory(factory);

Now you can finalize the authentication flow by obtaining credentials for your user, and then use those credentials to create the Adsense helper object and then send your signed requests to the API:

Credential credential = authFlow.complete(authorizationCode);
Adsense adsense = new Adsense(transport, credential, factory);
AdClients adClients = adsense.adclients.list().execute();

Python

The home of the Google APIs Client Library for Python is also the home of OAuth2Client, a library designed for connecting to resources protected by OAuth 2.0.

First create an OAuth2WebServerFlow object, passing the following parameters to the constructor:

  • the Client ID for your application
  • the Client Secret for your application
  • the scope you are requesting access to (AdSense in your case)
  • an HTTP User-Agent to identify this application
flow = OAuth2WebServerFlow(
  client_id='INSERT_CLIENT_ID_HERE',
  client_secret='INSERT_CLIENT_SECRET_HERE',
  scope='https://www.googleapis.com/auth/adsense',
  user_agent='your-beautiful-python-app/1.0')

We can perform the authentication calling the ‘run’ function imported from oauth2client.tools, storing the authentication data using a Storage object:

storage = Storage(‘adsense.dat’);
credentials = run(flow, storage);

If the flag ‘auth_local_webserver’ is raised (the default setting), oauth2client.tools will open the authentication URL on a running browser or on the system default browser. After the user performs the authentication, the authorization code will be read from the title of the page shown in the browser. If you don’t want this behaviour, you can disable it like this:

import gflags
gflags.FLAGS.auth_local_webserver = False

In this way we’ll have a flow similar to the one that we have seen in Java: the user will be asked to open the authentication URL in a browser window and then to copy and paste the authorization code back in the application. The only difference is that oauth2client.tools will take care of printing these messages and read the input from the user for us.

The last step is create an httplib2.Http object, authorize it with the previously obtained credentials and then send a request to the API:

http = httplib2.Http()
http = credentials.authorize(http)
service = build(‘adsense’, ‘v1’, http=http)
result = service.adclients().list().execute()

Cool! But I want to know more!

In this post we have seen examples of how to authenticate your native application using the Google implementation of the OAuth 2.0 protocol and the libraries that we are providing to simplify all of the tasks involved.

Now that we know how to perform authentication for both web and native applications, in my next post we are going to see different ways of storing the authentication data.