Has anyone implemented Cognito <confirmForgotPassw...
# http4k
d
Has anyone implemented Cognito confirmForgotPassword (or maybe it’s in connect and I’m just looking in the wrong place?)
d
It's not in connect but we do accept PRs... 🙂 https://github.com/http4k/http4k-connect/tree/master/amazon/cognito
remember to add it to the Fake 😉
And you'll also probably need to do ForgotPassword as well ..
d
ForgotPassword is already there, which is why I thought there was a chance that I’d just missed the confirm
So… I’m getting a response from AWS saying
{"__type":"SerializationException","Message":"Start of structure or map found where not expected."}
I assume that this is something to do with JSON adaptor bullshit and @JsonSerializable - I suppose that I can’t actually add extensions in my own codebase without using moshi/kotshi/bishBashBoshi?
d
Stick a debug on and look at the payload?
d
My assumption is that I haven’t generated any JSON mappings for my class unless I add the annotations and run some build step?
We’re using Jackson, I wondered if there is any way I could get a local (to our codebase) extension to use our Json not moshi?
d
what does your action look like?
wait a minute - ForgotPassword isn't supported by connect?
d
Hmm. You don’t have ForgotPassword, but you do have AdminResetUserPassword, which we are using
That sends a confirmation code
d
Copy code
@Http4kConnectAction
@JsonSerializable
data class SomeAction(
    val ClientMetadata: Map<String, String> = emptyMap()
) : CognitoAction<Unit>(Unit::class, Jackson) {
    override fun toResult(response: Response) = with(response) {
        when {
            status.successful -> Success(Unit)
            else -> Failure(asRemoteFailure(this))
        }
    }
}
d
Which I’m trying to submit with
Copy code
@Http4kConnectAction
data class ConfirmForgotPassword(
    val ClientId: ClientId,
    val Username: Username,
    val ConfirmationCode: ConfirmationCode,
    val Password: Password,
    val ClientMetadata: Map<String, String> = emptyMap(),
    val AnalyticsMetadata: AnalyticsMetadata? = null,
    val UserContextData: UserContextData? = null
) : CognitoAction<Unit>(Unit::class) {
    override fun toResult(response: Response) = with(response) {
        when {
            status.successful -> Success(Unit)
            else -> Failure(asRemoteFailure(this))
        }
    }
d
you can override the automarshalling to use Jackson
aren't we nice allowing you to do that? 😉
🤣 1
Copy code
: CognitoAction<Unit>(Unit::class, Jackson)
d
Aha -
autoMarshalling: AutoMarshalling = CognitoMoshi
You are, I think it’s safe to say, the most nicest http library
d
we are like - THE most considerate library authors on the planet.
I do hope you're going to contribute that back? you could even make a video about it
(not an onlyfans video - the other one)
a
image.png
d
Leaving some breadcrumbs for the next person to come this way - Jackson by sends properties with lowerFirstLetter even when the data class has eg
val Username: Username
So I’ve had to use
Copy code
@JsonNaming(PropertyNamingStrategies.UpperCamelCaseStrategy::class)
@Http4kConnectAction
data class ConfirmForgotPassword(
    val ClientId: ClientId,
    val Username: Username,
    val ConfirmationCode: ConfirmationCode,
    val Password: Password,
    val ClientMetadata: Map<String, String> = emptyMap(),
    val AnalyticsMetadata: AnalyticsMetadata? = null,
    val UserContextData: UserContextData? = null
) : CognitoAction<Unit>(Unit::class, autoMarshalling = CognitoJackson)
d
Yes - this is one of the reasons we don't use jackson..
a
🤔 are you overriding connect to use jackson simply to avoid duplicate marshallers in your classpath?
d
No, I’m trying to get another action running in my codebase without having to use moshi
just for that one, until I make a PR and have it built with moshi for me
👍 1
OK, looks like I have that working. I’ll think about what the fake could reasonable do and submit a PR
Thanks for the help. I take back everything I said about you
d
even the bad things?
d
I’ve said things that weren’t bad?
d
image.png
d
Released http4k-connect version 5.1.5.0 (See Changelog for details). 🙂