Skip to content

Conversation

@annagav
Copy link
Contributor

@annagav annagav commented Dec 16, 2025

What are the relevant tickets?

Related to https://github.com/mitodl/hq/issues/9622

Description (What does it do?)

Api to download the verifiable credential

How can this be tested?

Nothing should break.

Update VERIFIABLE_CREDENTIAL_SIGNER_URL from VC_SIGNER_URL

If you have already created a VerifiableCredentail then you can go ahead and try downloading it:

curl -X GET "http://mitxonline.odl.local:9080/api/v2/verifiable_course_credential/<credential_id>/download/"

Returns
{"id": "urn:uuid:cc7dfe00-44b4-4ff2-9369-5cf3fbd74cf6", "type": ["VerifiableCredential", "OpenBadgeCredential"], "proof": {"type": "Ed25519Signature2020", "created": "2025-12-17T19:38:16Z", "proofValue": "z3hP9Mctg5rJHqVNoLajo1czjZFrQ2qcTnXi3EEKJxycifhJ3QS3FdtyurxEtBD7jkQSNW73vH9bfyomJNDE55nUW", "proofPurpose": "assertionMethod", "verificationMethod": "did:key:z6MknNQD1WHLGGraFi6zcbGevuAgkVfdyCdtZnQTGWVVvR5Q#z6MknNQD1WHLGGraFi6zcbGevuAgkVfdyCdtZnQTGWVVvR5Q"}, "issuer": {"id": "did:key:z6MknNQD1WHLGGraFi6zcbGevuAgkVfdyCdtZnQTGWVVvR5Q", "name": "MIT Learn", "type": ["Profile"], "image": {"id": "https://github.com/digitalcredentials/test-files/assets/206059/01eca9f5-a508-40ac-9dd5-c12d11308894", "type": "Image", "caption": "MIT Learn logo"}}, "@context": ["https://www.w3.org/ns/credentials/v2", "https://purl.imsglobal.org/spec/ob/v3p0/context-3.0.3.json", "https://w3id.org/security/suites/ed25519-2020/v1"], "validFrom": "2025-12-17T19:38:16Z", "validUntil": "2030-01-01T00:00:00Z", "credentialSubject": {"type": ["AchievementSubject"], "identifier": [{"salt": "not-used", "type": "IdentityObject", "hashed": false, "identityHash": "Anna Gavrilman", "identityType": "name"}], "achievement": {"id": "urn:uuid:cc7dfe00-44b4-4ff2-9369-5cf3fbd74cf6", "name": "Case 10: Run Archived Enrollable, Future Enrollment Open", "type": ["Achievement"], "image": {"id": "https://github.com/digitalcredentials/test-files/assets/206059/01eca9f5-a508-40ac-9dd5-c12d11308894", "type": "Image", "caption": "MIT Learn Certificate logo"}, "criteria": {"narrative": "If you wanted to add some kind of criteria, e.g. a list of courses or modules, etc. CAN BE MARKDOWN"}, "description": "Anna Gavrilman has successfully completed all modules and earned a Course Certificate in Case 10: Run Archived Enrollable, Future Enrollment Open.", "achievementType": "Course"}, "activityEndDate": "2025-02-24T00:00:00Z", "activityStartDate": "2023-03-01T00:00:00Z"}}%

@github-actions
Copy link

github-actions bot commented Dec 16, 2025

OpenAPI Changes

Show/hide ## Changes for v0.yaml:
## Changes for v0.yaml:
2 changes: 0 error, 0 warning, 2 info
info	[endpoint-added] at head/openapi/specs/v0.yaml	
	in API GET /api/v2/verifiable_course_credential/{credential_id}/download/
		endpoint added

info	[endpoint-added] at head/openapi/specs/v0.yaml	
	in API GET /api/v2/verifiable_program_credential/{credential_id}/download/
		endpoint added



## Changes for v1.yaml:
2 changes: 0 error, 0 warning, 2 info
info	[endpoint-added] at head/openapi/specs/v1.yaml	
	in API GET /api/v2/verifiable_course_credential/{credential_id}/download/
		endpoint added

info	[endpoint-added] at head/openapi/specs/v1.yaml	
	in API GET /api/v2/verifiable_program_credential/{credential_id}/download/
		endpoint added



## Changes for v2.yaml:
2 changes: 0 error, 0 warning, 2 info
info	[endpoint-added] at head/openapi/specs/v2.yaml	
	in API GET /api/v2/verifiable_course_credential/{credential_id}/download/
		endpoint added

info	[endpoint-added] at head/openapi/specs/v2.yaml	
	in API GET /api/v2/verifiable_program_credential/{credential_id}/download/
		endpoint added



Unexpected changes? Ensure your branch is up-to-date with main (consider rebasing).

@annagav annagav force-pushed the ag/add_dc_api branch 2 times, most recently from dfcc33d to 3071ef6 Compare December 16, 2025 14:43
@annagav annagav marked this pull request as ready for review December 16, 2025 17:18
@annagav annagav changed the title Adding APIs for verifying, revoking a digital credential Adding APIs for downloading a digital credential Dec 17, 2025
Copy link
Contributor

@dsubak dsubak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good - I'll give it a quick test after standup, but this seems straightforward to me!

I had a few minor bits of feedback, but I'll approve it up front and you can take or leave any of my comments at your discretion!



@extend_schema(
description="Returns the json for the verifiable credential with the given ID, if it belongs to the user.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think right now this allows unauthenticated access, should we change the description?

Suggested change
description="Returns the json for the verifiable credential with the given ID, if it belongs to the user.",
description="Returns the json for the verifiable credential with the given ID.",

Comment on lines +613 to +616
credential = get_object_or_404(
VerifiableCredential,
pk=credential_id,
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth a comment that right now the Certificate and Credential UUID are the same (and it seems like that'll be the case, at least for the immediate future) which is why we can pipe it directly in as the primary key.

courses/utils.py Outdated
Comment on lines 256 to 258
def dc_url(path):
"""Returns the full url to the provided path"""
return urljoin(settings.DIGITAL_CREDENTIAL_ISSUER_URL, path)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we've got DIGITAL_CREDENTIAL_ISSUER_URL - we might be able to remove this for now?

Alternatively, we could use VERIFIABLE_CREDENTIAL_SIGNER_URL, keep the utility function and I'll rework the task hooks to use it - dealer's choice!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean removed for now


VC_SIGNER_URL = get_string(
name="VC_SIGNER_URL",
VERIFIABLE_CREDENTIAL_SIGNER_URL = get_string(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to change this over in api.request_verifiable_credential to match this new name, and in the env.example file too. I'm happy to do that in a follow on PR if you'd like!

@dsubak
Copy link
Contributor

dsubak commented Dec 18, 2025

Just tested it, works great!

@annagav annagav merged commit d8b0a88 into main Dec 18, 2025
9 checks passed
@annagav annagav deleted the ag/add_dc_api branch December 18, 2025 15:48
This was referenced Dec 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants