Skip to content

Conversation

@chingor13
Copy link
Collaborator

@chingor13 chingor13 commented May 16, 2019

The fancy automatic credentials for Application Default Credentials and CloudShell should be handled by google-auth-library. That library provides an adapter that can be used with google-http-client.

Note that this still provides the oauth2 helpers for handling 3-legged OAuth2.

@chingor13 chingor13 requested review from elharo and kolea2 May 16, 2019 19:40
@chingor13 chingor13 requested a review from a team as a code owner May 16, 2019 19:40
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label May 16, 2019
@chingor13 chingor13 merged commit 45825c4 into googleapis:master May 17, 2019
@Khyme
Copy link

Khyme commented Oct 8, 2019

Hello @chingor13

I don't understand how to correctly replace GoogleCredential.fromStream() with the new methods and adapter and keep a Credential response.

@asinbow
Copy link

asinbow commented Apr 1, 2020

Hello @chingor13

I don't understand how to correctly replace GoogleCredential.fromStream() with the new methods and adapter and keep a Credential response.

https://github.com/googleapis/google-auth-library-java#using-credentials-with-google-http-client

@chingor13 chingor13 deleted the deprecate-auth-classes branch April 1, 2020 16:21
rtyley added a commit to guardian/play-googleauth that referenced this pull request Nov 27, 2020
This change is only related to the Google-Group-checking code in
`play-googleauth`, which was using a deprecated class:

The `com.google.api.client.googleapis.auth.oauth2.GoogleCredential`
class in https://github.com/googleapis/google-api-java-client was
deprecated in May 2019 by googleapis/google-api-java-client#1258
...the deprecation advice recommends using the classes from the new
library: https://github.com/googleapis/google-auth-library-java

This commit switches to using the new
`com.google.auth.oauth2.ServiceAccountCredentials` class from the
`google-auth-library-oauth2-http` artifact. Given this new class, our
custom `com.gu.googleauth.GoogleServiceAccount` Scala case class is no
longer necessary, so has been removed, in favour of the user passing
us an instance of `ServiceAccountCredentials` - which is actually
easier for a user to generate! Here's an example of how you make and use
an instance of the new credentials:

```
import org.apache.commons.io.Charsets.UTF_8
import org.apache.commons.io.IOUtils
import com.google.auth.oauth2.ServiceAccountCredentials
import com.gu.googleauth.GoogleGroupChecker

val impersonatedUser: String = ... // email address of the 'impersonated' account
val serviceAccountCert: String = ... // from Google Developers Console
val credentials  =
  ServiceAccountCredentials.fromStream(IOUtils.toInputStream(serviceAccountCert, UTF_8))

val groupChecker = new GoogleGroupChecker(impersonatedUser, credentials)
```
rtyley added a commit to guardian/play-googleauth that referenced this pull request Nov 27, 2020
This change is only related to the Google-Group-checking code in
`play-googleauth`, which was using a deprecated class:

The `com.google.api.client.googleapis.auth.oauth2.GoogleCredential`
class in https://github.com/googleapis/google-api-java-client was
deprecated in May 2019 by googleapis/google-api-java-client#1258
...the deprecation advice recommends using the classes from the new
library: https://github.com/googleapis/google-auth-library-java

This commit switches to using the new
`com.google.auth.oauth2.ServiceAccountCredentials` class from the
`google-auth-library-oauth2-http` artifact. Given this new class, our
custom `com.gu.googleauth.GoogleServiceAccount` Scala case class is no
longer necessary, so has been deprecated, in favour of the user passing
us an instance of `ServiceAccountCredentials` - which is actually
easier for a user to generate! Here's an example of how you make and use
an instance of the new credentials:

```
import org.apache.commons.io.Charsets.UTF_8
import org.apache.commons.io.IOUtils
import com.google.auth.oauth2.ServiceAccountCredentials
import com.gu.googleauth.GoogleGroupChecker

val impersonatedUser: String = ... // email address of the 'impersonated' account
val serviceAccountCert: String = ... // from Google Developers Console
val credentials  =
  ServiceAccountCredentials.fromStream(IOUtils.toInputStream(serviceAccountCert, UTF_8))

val groupChecker = new GoogleGroupChecker(impersonatedUser, credentials)
```
rtyley added a commit to guardian/play-googleauth that referenced this pull request Nov 27, 2020
This change is only related to the Google-Group-checking code in
`play-googleauth`, which was using a deprecated class:

The `com.google.api.client.googleapis.auth.oauth2.GoogleCredential`
class in https://github.com/googleapis/google-api-java-client was
deprecated in May 2019 by googleapis/google-api-java-client#1258
...the deprecation advice recommends using the classes from the new
library: https://github.com/googleapis/google-auth-library-java

This commit switches to using the new
`com.google.auth.oauth2.ServiceAccountCredentials` class from the
`google-auth-library-oauth2-http` artifact. Given this new class, our
custom `com.gu.googleauth.GoogleServiceAccount` Scala case class is no
longer necessary, so has been deprecated, in favour of the user passing
us an instance of `ServiceAccountCredentials` - which is actually
easier for a user to generate! Here's an example of how you make and use
an instance of the new credentials:

```
import org.apache.commons.io.Charsets.UTF_8
import org.apache.commons.io.IOUtils
import com.google.auth.oauth2.ServiceAccountCredentials
import com.gu.googleauth.GoogleGroupChecker

val impersonatedUser: String = ... // email address of the 'impersonated' account
val serviceAccountCert: String = ... // from Google Developers Console
val credentials  =
  ServiceAccountCredentials.fromStream(IOUtils.toInputStream(serviceAccountCert, UTF_8))

val groupChecker = new GoogleGroupChecker(impersonatedUser, credentials)
```
rtyley added a commit to guardian/play-googleauth that referenced this pull request Nov 27, 2020
This change is only related to the Google-Group-checking code in
`play-googleauth`, which was using a deprecated class:

The `com.google.api.client.googleapis.auth.oauth2.GoogleCredential`
class in https://github.com/googleapis/google-api-java-client was
deprecated in May 2019 by googleapis/google-api-java-client#1258
...the deprecation advice recommends using the classes from the new
library: https://github.com/googleapis/google-auth-library-java

This commit switches to using the new
`com.google.auth.oauth2.ServiceAccountCredentials` class from the
`google-auth-library-oauth2-http` artifact. Given this new class, our
custom `com.gu.googleauth.GoogleServiceAccount` Scala case class is no
longer necessary, so has been deprecated, in favour of the user passing
us an instance of `ServiceAccountCredentials` - which is actually
easier for a user to generate! Here's an example of how you make and use
an instance of the new credentials:

```
import org.apache.commons.io.Charsets.UTF_8
import org.apache.commons.io.IOUtils
import com.google.auth.oauth2.ServiceAccountCredentials
import com.gu.googleauth.GoogleGroupChecker

val impersonatedUser: String = ... // email address of the 'impersonated' account
val serviceAccountCert: String = ... // from Google Developers Console
val credentials  =
  ServiceAccountCredentials.fromStream(IOUtils.toInputStream(serviceAccountCert, UTF_8))

val groupChecker = new GoogleGroupChecker(impersonatedUser, credentials)
```
rtyley added a commit to guardian/play-googleauth that referenced this pull request Nov 28, 2020
This change is only related to the Google-Group-checking code in
`play-googleauth`, which was using a deprecated class:

The `com.google.api.client.googleapis.auth.oauth2.GoogleCredential`
class in https://github.com/googleapis/google-api-java-client was
deprecated in May 2019 by googleapis/google-api-java-client#1258
...the deprecation advice recommends using the classes from the new
library: https://github.com/googleapis/google-auth-library-java

This commit switches to using the new
`com.google.auth.oauth2.ServiceAccountCredentials` class from the
`google-auth-library-oauth2-http` artifact. Given this new class, our
custom `com.gu.googleauth.GoogleServiceAccount` Scala case class is no
longer necessary, so has been deprecated, in favour of the user passing
us an instance of `ServiceAccountCredentials` - which is actually
easier for a user to generate! Here's an example of how you make and use
an instance of the new credentials:

```
import org.apache.commons.io.Charsets.UTF_8
import org.apache.commons.io.IOUtils
import com.google.auth.oauth2.ServiceAccountCredentials
import com.gu.googleauth.GoogleGroupChecker

val impersonatedUser: String = ... // email address of the 'impersonated' account
val serviceAccountCert: String = ... // from Google Developers Console
val credentials  =
  ServiceAccountCredentials.fromStream(IOUtils.toInputStream(serviceAccountCert, UTF_8))

val groupChecker = new GoogleGroupChecker(impersonatedUser, credentials)
```
rtyley added a commit to guardian/play-googleauth that referenced this pull request Nov 28, 2020
This change is only related to the Google-Group-checking code in
`play-googleauth`, which was using a deprecated class:

The `com.google.api.client.googleapis.auth.oauth2.GoogleCredential`
class in https://github.com/googleapis/google-api-java-client was
deprecated in May 2019 by googleapis/google-api-java-client#1258
...the deprecation advice recommends using the classes from the new
library: https://github.com/googleapis/google-auth-library-java

This commit switches to using the new
`com.google.auth.oauth2.ServiceAccountCredentials` class from the
`google-auth-library-oauth2-http` artifact. Given this new class, our
custom `com.gu.googleauth.GoogleServiceAccount` Scala case class is no
longer necessary, so has been deprecated, in favour of the user passing
us an instance of `ServiceAccountCredentials` - which is actually
easier for a user to generate! Here's an example of how you make and use
an instance of the new credentials:

```
import org.apache.commons.io.Charsets.UTF_8
import org.apache.commons.io.IOUtils
import com.google.auth.oauth2.ServiceAccountCredentials
import com.gu.googleauth.GoogleGroupChecker

val impersonatedUser: String = ... // email address of the 'impersonated' account
val serviceAccountCert: String = ... // from Google Developers Console
val credentials  =
  ServiceAccountCredentials.fromStream(IOUtils.toInputStream(serviceAccountCert, UTF_8))

val groupChecker = new GoogleGroupChecker(impersonatedUser, credentials)
```
rtyley added a commit to guardian/play-googleauth that referenced this pull request Dec 1, 2020
This change is only related to the Google-Group-checking code in
`play-googleauth`, which was using a deprecated class:

The `com.google.api.client.googleapis.auth.oauth2.GoogleCredential`
class in https://github.com/googleapis/google-api-java-client was
deprecated in May 2019 by googleapis/google-api-java-client#1258
...the deprecation advice recommends using the classes from the new
library: https://github.com/googleapis/google-auth-library-java

This commit switches to using the new
`com.google.auth.oauth2.ServiceAccountCredentials` class from the
`google-auth-library-oauth2-http` artifact. Given this new class, our
custom `com.gu.googleauth.GoogleServiceAccount` Scala case class is no
longer necessary, so has been deprecated, in favour of the user passing
us an instance of `ServiceAccountCredentials` - which is actually
easier for a user to generate! Here's an example of how you make and use
an instance of the new credentials:

```
import org.apache.commons.io.Charsets.UTF_8
import org.apache.commons.io.IOUtils
import com.google.auth.oauth2.ServiceAccountCredentials
import com.gu.googleauth.GoogleGroupChecker

val impersonatedUser: String = ... // email address of the 'impersonated' account
val serviceAccountCert: String = ... // from Google Developers Console
val credentials  =
  ServiceAccountCredentials.fromStream(IOUtils.toInputStream(serviceAccountCert, UTF_8))

val groupChecker = new GoogleGroupChecker(impersonatedUser, credentials)
```
rtyley added a commit to guardian/play-googleauth that referenced this pull request Dec 1, 2020
This change is only related to the Google-Group-checking code in
`play-googleauth`, which was using a deprecated class:

The `com.google.api.client.googleapis.auth.oauth2.GoogleCredential`
class in https://github.com/googleapis/google-api-java-client was
deprecated in May 2019 by googleapis/google-api-java-client#1258
...the deprecation advice recommends using the classes from the new
library: https://github.com/googleapis/google-auth-library-java

This commit switches to using the new
`com.google.auth.oauth2.ServiceAccountCredentials` class from the
`google-auth-library-oauth2-http` artifact. Given this new class, our
custom `com.gu.googleauth.GoogleServiceAccount` Scala case class is no
longer necessary, so has been deprecated, in favour of the user passing
us an instance of `ServiceAccountCredentials` - which is actually
easier for a user to generate! Here's an example of how you make and use
an instance of the new credentials:

```
import org.apache.commons.io.Charsets.UTF_8
import org.apache.commons.io.IOUtils
import com.google.auth.oauth2.ServiceAccountCredentials
import com.gu.googleauth.GoogleGroupChecker

val impersonatedUser: String = ... // email address of the 'impersonated' account
val serviceAccountCert: String = ... // from Google Developers Console
val credentials  =
  ServiceAccountCredentials.fromStream(IOUtils.toInputStream(serviceAccountCert, UTF_8))

val groupChecker = new GoogleGroupChecker(impersonatedUser, credentials)
```
rtyley added a commit to guardian/play-googleauth that referenced this pull request Dec 1, 2020
This change is only related to the Google-Group-checking code in
`play-googleauth`, which was using a deprecated class:

The `com.google.api.client.googleapis.auth.oauth2.GoogleCredential`
class in https://github.com/googleapis/google-api-java-client was
deprecated in May 2019 by googleapis/google-api-java-client#1258
...the deprecation advice recommends using the classes from the new
library: https://github.com/googleapis/google-auth-library-java

This commit switches to using the new
`com.google.auth.oauth2.ServiceAccountCredentials` class from the
`google-auth-library-oauth2-http` artifact. Given this new class, our
custom `com.gu.googleauth.GoogleServiceAccount` Scala case class is no
longer necessary, so has been deprecated, in favour of the user passing
us an instance of `ServiceAccountCredentials` - which is actually
easier for a user to generate! Here's an example of how you make and use
an instance of the new credentials:

```
import org.apache.commons.io.Charsets.UTF_8
import org.apache.commons.io.IOUtils
import com.google.auth.oauth2.ServiceAccountCredentials
import com.gu.googleauth.GoogleGroupChecker

val impersonatedUser: String = ... // email address of the 'impersonated' account
val serviceAccountCert: String = ... // from Google Developers Console
val credentials  =
  ServiceAccountCredentials.fromStream(IOUtils.toInputStream(serviceAccountCert, UTF_8))

val groupChecker = new GoogleGroupChecker(impersonatedUser, credentials)
```
@leonroy
Copy link

leonroy commented Jan 14, 2021

Hi, we're using this class like so:

Credential googleCredential = new GoogleCredential.Builder()
    .setTransport(httpTransport)
    .setJsonFactory(jsonFactory)
    .setClientSecrets(googleProvider.getClientId(), googleProvider.getClientSecret())
    .build();

Wondering if this Deprecated class is subject to the standard Remove after 18 months Google policy?

Also any suggestions on what we move the above to?

@elharo
Copy link
Contributor

elharo commented Jan 14, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants