Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[OID4VCI] Revisit and fix OAuthClient.credentialOfferRequest() #46001

@tdiesler

Description

@tdiesler

Description

Currently we send a CredentialOffer request like this ...

        CredentialOfferResponse credentialOfferResponse = oauth.oid4vc()
                .credentialOfferRequest()
                .endpoint(offerUri)
                .send();
        int statusCode = credentialOfferResponse.getStatusCode();
        if (HttpStatus.SC_OK != statusCode) {
            throw new IllegalStateException(credentialOfferResponse.getErrorDescription() != null
                    ? credentialOfferResponse.getErrorDescription()
                    : "Request failed with status " + statusCode);
        }
        CredentialsOffer credOffer = credentialOfferResponse.getCredentialsOffer();

or

        CredentialOfferResponse credentialOfferResponse = oauth.oid4vc()
                .credentialOfferRequest()
                .nonce(credOfferUri.getNonce())
                .send();
        int statusCode = credentialOfferResponse.getStatusCode();
        if (HttpStatus.SC_OK != statusCode) {
            throw new IllegalStateException(credentialOfferResponse.getErrorDescription() != null
                    ? credentialOfferResponse.getErrorDescription()
                    : "Request failed with status " + statusCode);
        }

This code has several issues ...

  • It (again often) relies on constructing the endpoint Url externally
  • From a Wallet perspective - it has the complete offerUrl (nonce is a Keycloak proprietary thing)
  • From our test API perspective we have the CredentialOfferURI, which can be used directly
  • error handling should not have to be duplicated for every request

Value Proposition

  • use credential offer url or CredentialOfferURI directly
  • error handling by CredentialOfferResponse

Goals

Cleaner and more reliable code

Non-Goals

--

Discussion

No response

Notes

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions