diff --git a/src/main/kotlin/id/walt/model/oidc/SIOPv2Response.kt b/src/main/kotlin/id/walt/model/oidc/SIOPv2Response.kt index 3173741d..56c95d82 100644 --- a/src/main/kotlin/id/walt/model/oidc/SIOPv2Response.kt +++ b/src/main/kotlin/id/walt/model/oidc/SIOPv2Response.kt @@ -54,13 +54,14 @@ data class SIOPv2Response( companion object { fun fromFormParams(params: Map): SIOPv2Response { val vpTokenStr = params["vp_token"] ?: throw Exception("vp_token parameter must be set") - val presentationSubmissionStr = - params["presentation_submission"] ?: throw Exception("presentation_submission parameter must be set") + val idToken = params["id_token"] + val presentationSubmissionStr = params["presentation_submission"] return SIOPv2Response( vp_token = OIDCUtils.fromVpToken(vpTokenStr), - presentation_submission = KlaxonWithConverters().parse(presentationSubmissionStr) + presentation_submission = presentationSubmissionStr?.let { KlaxonWithConverters().parse(it) } + ?: idToken?.let { IDToken.parse(it)?.vpTokenRef?.presentation_submission } ?: throw Exception("Could not parse presentation_submission parameter"), - id_token = params["id_token"], + id_token = idToken, state = params["state"] ) }