1

Currently, I am using the following code snippet to use as a credential for accessing the Gmail API on Java / Kotlin.

val credentials = GoogleCredential.Builder()
                    .setClientSecrets(clientSecrets)
                    .setJsonFactory(GsonFactory.getDefaultInstance())
                    .setTransport(GoogleNetHttpTransport.newTrustedTransport())
                    .build()
                    .apply {
                        this.refreshToken = refreshToken
                        refreshToken()
                    }

This is currently working, however, the GoogleCredential class is deprecated. Is there a non-deprecated version of accomplishing the same thing? I have tried to find the equivalent but having no luck looking through Google API docs so far.

I have access to the client secrets (in a downloaded .json file) and the refreshToken retrieved on the last authorization flow.

Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214

0 Answers0