How to use google cloud oauth2 for container APIs

11/20/2014

I am trying to access google container engine APIs with Oauth2 authentication. I am not to find scope and services for it. I feel https://www.googleapis.com/auth/cloud-platform scope is the best suited.

Not sure, what to do once you get credential object for container API as don't able to find any container services jar.

I see most of the service has service class and Builder that class. See below code is simple if we know Service class.

    GoogleCredential credential = new GoogleCredential.Builder()
            .setTransport(httpTransport)
            .setJsonFactory(JSON_FACTORY)
            .setServiceAccountId(emailAddress)
            .setServiceAccountPrivateKeyFromP12File(new File("E:\\container-44a31ad09130.p12"))
            .setServiceAccountScopes(PubsubScopes.all())
            .build();
    client = new Pubsub.Builder(TRANSPORT, JSON_FACTORY, credential)
            .setApplicationName(APPLICATION_NAME)
            .build();
-- Ashish Jain
google-kubernetes-engine

1 Answer

12/3/2014

Sorry I don't know much about the Java client libraries, but I can confirm that https://www.googleapis.com/auth/cloud-platform is the correct scope to use.

-- Robert Bailey
Source: StackOverflow