Google OAuth2 on Cordova

I just want to wrap my existing WebApp with Cordova (iOS, Android not tested so far). Now I’m stuck in bringing google authentication to work. I couldn’t find any solution on the web so far.

I’m using the official accounts-google package. Also I configured the REVERSED_CLIENT_ID in mobile-config.js. The login in the normal browser environment works perfectly fine.

The first time I click the login button I’m redirected to the google window where I must enter my google credentials. Then this window closes but I’m still not logged in and the server throws an error:

{ error: 'redirect_uri_mismatch', error_description: 'Bad Request' } } }

The next time I click nothing happens except for another error on the server:

{ error: 'invalid_grant', error_description: 'Bad Request' } } }

Now I re-deploy the app on the iPhone and then the first login attempt is successful (without seeing the google auth screen).

But the next time I get the same errors as mentionend before (first the redirect_uri_mismatch and then only invalid_grant for each further try).

It also doesn’t matter if the app is running in development mode or on the staging system.

Anyone has an idea what might be wrong?