I've tried this code and it works.
But it uses Oauth and it requires a redirect. Is there any way to use just an API key without having to redirect to a browser?
I understand I can just make http request using this:
https://developers.google.com/webmaster-tools/search-console-api-original/v3/
But I wonder if there's any Java API I can use, like in the first example.