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

Access token lost in transit, when using UserCredentials ToBuilder() #992

Closed
qcastel opened this issue Sep 7, 2022 · 0 comments · Fixed by #993
Closed

Access token lost in transit, when using UserCredentials ToBuilder() #992

qcastel opened this issue Sep 7, 2022 · 0 comments · Fixed by #993

Comments

@qcastel
Copy link
Contributor

qcastel commented Sep 7, 2022

Environment details

When using the library, I found a bug in the UserCredentials#ToBuilder()
It's not calling super and therefore we lost the access token

Steps to reproduce

UserCredentialsTest.java

  @Test
  public void toBuilder() throws IOException {
    final URI tokenServer1 = URI.create("https://foo1.com/bar");
    AccessToken accessToken = new AccessToken(ACCESS_TOKEN, null);
    MockHttpTransportFactory httpTransportFactory = new MockHttpTransportFactory();
    UserCredentials credentials =
            UserCredentials.newBuilder()
                    .setClientId(CLIENT_ID)
                    .setClientSecret(CLIENT_SECRET)
                    .setRefreshToken(REFRESH_TOKEN)
                    .setAccessToken(accessToken)
                    .setHttpTransportFactory(httpTransportFactory)
                    .setTokenServerUri(tokenServer1)
                    .build();

    credentials.toBuilder().build();
    UserCredentials otherCredentials = credentials.toBuilder().build();
    assertEquals(credentials, otherCredentials);
  }

Will shortly provide a PR for this

qcastel added a commit to qcastel/google-auth-library-java that referenced this issue Sep 7, 2022
qcastel added a commit to qcastel/google-auth-library-java that referenced this issue Sep 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant