If you're running in Compute Engine or App Engine, authentication should "just work".
If you're developing locally, the easiest way to authenticate is using the Google Cloud SDK:
$ gcloud auth login
If you're running your application elsewhere, you should download a service account JSON keyfile and point to it using an environment variable:
$ export GOOGLE_APPLICATION_CREDENTIALS="/path/to/keyfile.json"