Skip to content

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

@qcastel

Description

@qcastel

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions