AccessRefreshToken not serialized while using Micronaut Serialization

227 Views Asked by At

I have a Java-library which uses below dependencies

dependencies {
    annotationProcessor "io.micronaut:micronaut-inject-java:3.5.3"
    annotationProcessor "io.micronaut:micronaut-validation:3.5.3"
    annotationProcessor('io.micronaut.serde:micronaut-serde-processor:1.1.0')
    annotationProcessor("io.micronaut.security:micronaut-security-annotations")

    implementation("io.micronaut.serde:micronaut-serde-jackson:1.1.0")
    //... other properties
}

In the other application where I am consuming that library I have the below dependency

dependencies {
    // other dependencies
    implementation 'fete.bird:common:1.0.0'
}

Creating a JWT token

When creating the JWT AccessRefreshToken
    private BearerAccessRefreshToken shouldCreateAValidSignedJwtToken(Map<CharSequence, CharSequence> claims) {
        UsernamePasswordCredentials creds = new UsernamePasswordCredentials("[email protected]", "RockStar.1");
        HttpRequest request = HttpRequest.POST("/login", creds)
                .headers(claims);
        HttpResponse<BearerAccessRefreshToken> rsp = client.toBlocking().exchange(request, BearerAccessRefreshToken.class);
        bearerAccessRefreshToken = rsp.body();
        return bearerAccessRefreshToken;
    }

The access token in null, as from the package io.micronaut.security.token.jwt.render, it has a dependency of com.fasterxml.jackson.annotation

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.micronaut.core.annotation.Introspected;

@Introspected
public class AccessRefreshToken {

    @JsonProperty("access_token")
    private String accessToken;
}

enter image description here

Removing implementation("io.micronaut.serde:micronaut-serde-jackson:1.1.0") from the library the serialization/deserializtion is working fine.

How can I make this work, I tried the below code included in the library project from the documentation https://micronaut-projects.github.io/micronaut-serialization/1.2.0/guide/index.html But didn't work

configurations.all {
    resolutionStrategy.dependencySubstitution {
        substitute(module("io.micronaut:micronaut-jackson-databind"))
            .using(module("io.micronaut.serde:micronaut-serde-jackson:1.2.0"))
    }
}

Seems like an issue, just posted a bug https://github.com/micronaut-projects/micronaut-security/issues/1066

0

There are 0 best solutions below