How to set Credentials for Publisher for Google PubSub

Viewed 1686

I am using the newer version of PubSub - Publisher API

I have a P12 file and am building the credential like this:

GoogleCredential credential = new GoogleCredential.Builder()
            .setTransport(transport)
            .setJsonFactory(JSON_FACTORY)
            .setServiceAccountId(serviceAccount)
            .setServiceAccountScopes(Arrays.asList("https://www.googleapis.com/auth/pubsub")) 
            .setServiceAccountPrivateKeyFromP12File(new File(keyFile))
            .build();

How do I set the credentials on the Publisher? Also, is there a way to get the static scope string "https://www.googleapis.com/auth/pubsub"

1 Answers
Related