How to access Google APIs and services using Android


I already did a post on how to access Google APIs and services using various language. It is now time for a quick tutorial on accessing Google APIs and services using Android. More precisely, it will look at the configuration that needs to be done on Google APIs Console in order to grant access to your Android application.

Disclaimer: I have not yet published an application using this, so it is possible that something is missing. I will update this post as soon as I have more information (or remove this disclaimer if nothing more is needed).

Basic setup

In my other post, I already went over the basic setup. You will need to follow two of the sections in the first post: Enable needed APIs and Setup OAuth Consent Screen. This will configure the basis of your Google project.

Gather project information

Before even going to the Google APIs Console, you will need to find two information from your Android Application:

  1. Your package name (can be found in the AndroidManifest.xml file of your application);
  2. The SHA1 fingerprint from your application

Assuming that you are using Gradle, you can run the android/signingReport task in your app context. The output of this task will be shown in your Gradle console. Looking at the output from that task, you’ll be able to find the SHA1 signature associated with your application.

Create credentials

With the previous information in hand, you can now go in the Google APIs console to allow your application to connect. In order to do so, you’ll need to go into the Credentials section, hit Create credentials and select OAuth Client ID.

The next page is the one where you will need all that information you gathered. The first thing you’ll need to do is select the type of application: Android. With this done, you will be able to select the remaining options:

  1. Name
    This is the name of your application, it is used only in the Google APIs console;
  2. Signing-certificate fingerprint
    This is the SHA1 signature you extracted from your project in the previous step;
  3. Package name
    This is the package name you extracted in the previous step;

Creating a new credential for Android

Creating a new credential for Android

Specifying the android credential information

Specifying the android credential information

All done! Your Android application should now be able to connect to the services.


Tagged , . Bookmark the permalink.

Leave a Reply