Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove AuthCredentials and related classes, use google-auth-library-java instead #1375

Merged
merged 4 commits into from
Nov 8, 2016

Conversation

mziccard
Copy link
Contributor

@mziccard mziccard commented Nov 7, 2016

This PR gets rid of our AuthCredentials classes and uses google-auth-library-java instead.

@mziccard mziccard added the auth label Nov 7, 2016
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Nov 7, 2016
@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 84.152% when pulling c3d396d on mziccard:refactor-auth into e4fb76b on GoogleCloudPlatform:master.

@mziccard
Copy link
Contributor Author

mziccard commented Nov 7, 2016

@lesv @garrettjonesgoogle care to have a look?

Copy link
Contributor

@lesv lesv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - but give folks a few hours to respond to my question on the README.


To access Google Cloud services, you first need to ensure that the necessary Google Cloud APIs are
enabled for your project. To do this, follow the instructions on the
[authentication document](https://github.com/GoogleCloudPlatform/gcloud-common/blob/master/authentication/readme.md#authentication)

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

First, ensure that the necessary Google Cloud APIs are enabled for your project. To do this, follow the instructions on the [authentication document](https://github.com/GoogleCloudPlatform/gcloud-common/blob/master/authentication/readme.md#authentication) shared by all the gcloud language libraries.
`google-cloud-java` uses
[https://github.com/google/google-auth-library-java](https://github.com/google/google-auth-library-java)
to authenticate requests. `google-auth-library-java` supports a wide range of authentication types,

This comment was marked as spam.

This comment was marked as spam.

* If you already have an OAuth2 access token, you can use it to authenticate (notice that in this case the access token will not be automatically refreshed):
* If running locally for development/testing, you can use the
[Google Cloud SDK](https://cloud.google.com/sdk/). Create Application Default Credentials with
`gcloud auth application-default login`, `google-cloud` will automatically detect such

This comment was marked as spam.

`gcloud auth application-default login`, `google-cloud` will automatically detect such
credentials.
* If you already have an OAuth2 access token, you can use it to authenticate (notice that in this
case the access token will not be automatically refreshed):

This comment was marked as spam.

3. Key file pointed to by the GOOGLE_APPLICATION_CREDENTIALS environment variable
4. Google Cloud SDK credentials
5. Compute Engine credentials
1. Credentials file pointed to by the `GOOGLE_APPLICATION_CREDENTIALS` environment variable

This comment was marked as spam.

@@ -102,7 +102,7 @@ You can test against a remote Datastore emulator as well. To do this, set the `
DatastoreOptions options = DatastoreOptions.newBuilder()
.setProjectId("my-project-id") // must match project ID specified on remote machine
.setHost("http://<hostname of machine>:<port>")
.setAuthCredentials(AuthCredentials.noAuth())
.setNoCredentials()

This comment was marked as spam.

This comment was marked as spam.

.build();
BigQueryOptions otherOptions = options.toBuilder()
.setProjectId("p2")
.setAuthCredentials(null)
.setCredentials(null)

This comment was marked as spam.

This comment was marked as spam.

@@ -28,7 +28,7 @@

private static final String BIGQUERY_SCOPE = "https://www.googleapis.com/auth/bigquery";
private static final Set<String> SCOPES = ImmutableSet.of(BIGQUERY_SCOPE);
private static final long serialVersionUID = -8592198255032667206L;
private static final long serialVersionUID = -2437598817433266049L;

This comment was marked as spam.

This comment was marked as spam.

* @return the builder
* @throws NullPointerException if {@code credentials} is {@code null}. To disable
* authentication use {@link Builder#setNoCredentials()}

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 84.143% when pulling 96c2b60 on mziccard:refactor-auth into e4fb76b on GoogleCloudPlatform:master.

@garrettjonesgoogle
Copy link
Member

LGTM

@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 84.145% when pulling e8f9f6e on mziccard:refactor-auth into e4fb76b on GoogleCloudPlatform:master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants