Bryan Mytko

Software and stuff.

Google Play Oauth

July 26, 2016

Pokèmon Go is everywhere, especially in New York City, but who has time for this:

I spent some time looking into how the game worked from a developer's perspective and came across this demo which allows full communication with Niantic's API. Since it was just a demo and written in Python, I decided to try to build a Ruby version to suit my own needs but quickly ran into a major problem: how to obtain the OAuth token.

The python version was using this library called gpsoauth by Simon Weber. It's an implementation of the flow described in this article: Inside Android Play Services Magic OAuth flow.

So down the rabbit hole we go.

It was pretty easy to port most of this to a Ruby gem with the exception of the EncryptedPasswd parameter part, which is described in this article. I finally got it working after looking at the Python version, the Java version and the C# Port as well as many hours of trial and error and reading up on crytpo terms and Ruby docs.

The gem is published to Ruby Gems and the source is available on Github. It could potentially be used to authenticate any Ruby app that needs to communicate with Play services like Google Music, Google+, Drive, etc.

Now, five days later, finally time to start hacking on some actual Pokèmon Go stuff...