Search code examples
javaauthenticationbigtablegoogle-cloud-bigtable

Bigtable authentication in java


I am looking for an alternative way to authenticate in Bigable. Default approach involves the environment variable, which concerns me.

I found GoogleCredential class. It can read json key file with fromStream, but how to use the new instance of GoogleCredential. There is no method to setApplicationDefault(). I need override it somehow.

HBase code doesn't know anything about GoogleCredential.


Solution

  • EDIT 12/6/2016

    Default Auth now requires gcloud auth application-default login to use your user account for API calls. You can also do:

    $ gcloud iam service-accounts create my-account $ gcloud iam service-accounts keys create key.json [email protected] $ export GOOGLE_APPLICATION_CREDENTIALS=key.json $ ./my_applicaiton.sh

    Old Text

    For most things, the Default Auth is enough. If you've done gcloud init or it's predecessor gcloud auth login it should generally be enough. (EDIT - gcloud beta auth application-default login is now used for API access). There are some special circumstances where it won't be, such as if you are running locally inside a Docker container. Then your Default Auth won't have been setup correctly and you need to set GOOGLE_APPLICATION_CREDENTIALS.

    For completeness, it is also possible to set the google.bigtable.auth.json.keyfile key in your hbase-site.xml file if you are doing some cross project activities, but that should be very rare.