HOWTO create GoogleCredential by using Service Account JSON <p>I am using the Java SDK for <code>Android Publisher v2</code> and <code>Oauth2 v2</code>. Once I created the service account I was provided with a JSON of <code>Google Play Android Developer</code> service account with client id, email, private key etc. I have tried to look around and figure out how to create a Credential so that I use the AndoirdPublisher service to fetch info on my Android App's users subscriptions, entitlements etc and store this info on our backend servers.</p> <p>I am getting hard time trying to figure out how to go about this. None of the documentations I have seen so far help in creating <code>GoogleCredential</code> using the downloaded JSON. </p> <p>For example there is this <a href="https://developers.google.com/identity/protocols/OAuth2ServiceAccount" rel="nofollow">documentation</a> but it mentions only about P12 file and not the JSON. I want to avoid P12 if possible since I have multiple clients &amp; I would like to save this JSON in some sort of database &amp; then use it to create credential for each client.</p> <p>Just to clarify I am trying to create the GoogleCredential object as described here,</p> <pre><code>import com.google.api.client.googleapis.auth.oauth2.GoogleCredential; import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport; import com.google.api.client.http.HttpTransport; import com.google.api.client.json.JsonFactory; import com.google.api.client.json.jackson2.JacksonFactory; import com.google.api.services.sqladmin.SQLAdminScopes; // ... String emailAddress = "123456789000-abc123def456@developer.gserviceaccount.com"; JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance(); HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport(); GoogleCredential credential = new GoogleCredential.Builder() .setTransport(httpTransport) .setJsonFactory(JSON_FACTORY) .setServiceAccountId(emailAddress) .setServiceAccountPrivateKeyFromP12File(new File("MyProject.p12")) .setServiceAccountScopes(Collections.singleton(SQLAdminScopes.SQLSERVICE_ADMIN)) .build(); </code></pre> <p>But instead of setting the Service Account using P12 File like so <code>setServiceAccountPrivateKeyFromP12File()</code>, I want to use the JSON that carries the same info &amp; generated when I created the service account.</p>