I'm kinda new to Google SDK and I'm trying to implement a Google sign-in button in my app so users can login with their Google accounts.
I've added a SignInButton and handled the basic authentication flow with a PlusClient object. I also use an AsyncTask to get the Auth Token from GoogleAuthUtil. once I successfully get the token, I call LoginActivity.finish() and allow access to my app.
When I click the SignInButton I get the following:
- prompts a window to choose between my google accounts.
- A permissions screen asking me to confirm that this app would like to know your name, basic info etc.. to which I click OK.
- a weird notification warning icon (triangle with exclamation mark inside) that says "sign-in request"
- after clicking the notification, I see a quick "signing in.." screen for a few seconds and then back to step 2 - to which I click ok again.
- clicking the sign in button again logs me in successfully.
This flow is obviously not as it should be, so my questions are:
- Why do I get the ask for permissions screen twice? and also everytime I try to login?
- How do I get rid of that weird warning notification and just login when finished?
Using Android SDK v4.2 with Play Services SDK v10
EDIT
Ok, so kind of a stupid question, but I still haven't figured it all out yet.
It turns out I was using GoogleAuthUtil.getTokenWithNotification which sends a push notification if the method fails with a recoverable action. So I changed it back to GoogleAuthUtil.getToken and now I recover it programmatically which is better.
But I still get the intervention screen, once when I call result.startResolutionForResult inside onConnectionFailed(ConnectionResult result) when I try to connect and the second time after calling startActivityForResult when calling GoogleAuthUtil.getToken. This is still a mystery...
EDIT 2
The first question (second one is answered above)) about repeated permissions prompted to the user is discussed in here