Tuesday, 23 September 2014

Android Google+ Sign In Problem

Last week I was working to implement Google+ authentication in an Android app. The process is well documented on Android Developers and Google provides also a sample app on GitHub.

As stated in the quickstart, before start coding you should create a new project into the Google Developer Console, in order to register your app on the Google APIs. You have to provide your Android certificate SHA1 fingerprint and your app package name, then everything should work.

Clearly, it didn't.

While trying to login with the sample app I got back on the log an error saying:

ConnectionResult.getErrorCode() = 4

According to the documentation for ConnectionResult code 4 stands for: SIGN_IN_REQUIRED, but no other explanation is given. After many hours of searches and tests, I discovered that I was simply missing the definition of the sign-in screen in the Google Developer Console.

In the lateral menu of the Developer Console, select APIs & auth and the Consent screen fill in the required fields, save, give it a couple of minutes and you should be OK.

Hope it helps someone.