Search code examples
pythonoauthgoogle-oauth

Google OAuth2 callbacks calls me without parameters


I have been running a service for some months now using Google's OAuth2 authentication. Most of the time everything works well, but there are occasional issues with callbacks coming back empty from Google to me: Something along the lines of 1 out of 15 callbacks arrives at my service completely without parameters in the GET request. Just a naked /my-callback-url request, no parameters at all.

I'm having quite some difficulty explaining this behaviour and neither can I find many references to it when searching the net.

I'm also so far unable to re-create this phenomenon in my own development environment, so my solution ideas have had to be mostly speculation: My first hunch at a quick-n-dirty work around was to re-generate the OAuth request URL and return a 302 redirect response back so Google can have another go. But that sounds like taking the risk of creating an infinite redirect loop if it would turn out that the problem originates from my code. I would very much prefer to understand what's actually going on.

Do any of you have experience of 'empty' OAuth2 callbacks from Google? And in that case, what would be the most sensible way of handling them? Or are there a typical error when generating the authentication URL's that causes this behaviour (I'm using Python & Requests-OAuthlib) to handle my OAuth2 interaction).


Solution

  • I suspect that these requests are not redirects back from Google. There are crawlers and other hackers trying to hit every endpoint that they find on the web. So these could be just abusive requests. If you can correlate the request with an empty parameter with a request that redirected from your server (based on IP address or a cookie you set before redirecting to Google) then we can try to investigate further.