ported from https://github.com/liquidlabs/phonegap-oauth-google-api-mobile