I have a web server that communicates with an IOS app to get an offline access token/refresh token pair for users. This seemed to be working well until recently when without any code changes, most authentication requests to google started failing. I have been attempting to debug "invalid_grant"
errors that occur seemingly non-deterministically. A single user may try to authenticate multiple times with some of the attempts accepted by google and some not. The errors that we are seeing come in the following form (we're using the google java api client):
com.google.api.client.auth.oauth2.TokenResponseException400 Bad Request { "error" : "invalid_grant", "error_description" : "Invalid code." }
at com.google.api.client.auth.oauth2.TokenResponseException.from(TokenResponseException.java:105)
at com.google.api.client.auth.oauth2.TokenRequest.executeUnparsed(TokenRequest.java:287)
at com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeTokenRequest.execute(GoogleAuthorizationCodeTokenRequest.java:158)
I have tried ensuring that the server we are running this on has a properly synced clock with ntp.
I'm at a bit of a loss here on how to proceed. How would you debug this?