-
Notifications
You must be signed in to change notification settings - Fork 2
Adding APIs for downloading a digital credential #3149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
OpenAPI ChangesShow/hide ## Changes for v0.yaml:Unexpected changes? Ensure your branch is up-to-date with |
86bcd76 to
d9a5e35
Compare
dfcc33d to
3071ef6
Compare
fc90b18 to
5d0286f
Compare
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
7e850e1 to
3c34633
Compare
9caf68f to
db74b7a
Compare
28714d5 to
d43f9a9
Compare
9d2bb02 to
a9191d1
Compare
4ee4eb1 to
72a362e
Compare
b1a74b9 to
dcac06f
Compare
dsubak
left a comment
There was a problem hiding this 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!
courses/views/v2/__init__.py
Outdated
|
|
||
|
|
||
| @extend_schema( | ||
| description="Returns the json for the verifiable credential with the given ID, if it belongs to the user.", |
There was a problem hiding this comment.
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?
| 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.", |
| credential = get_object_or_404( | ||
| VerifiableCredential, | ||
| pk=credential_id, | ||
| ) |
There was a problem hiding this comment.
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
| def dc_url(path): | ||
| """Returns the full url to the provided path""" | ||
| return urljoin(settings.DIGITAL_CREDENTIAL_ISSUER_URL, path) |
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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!
|
Just tested it, works great! |
8b12ce2 to
d914e44
Compare
for more information, see https://pre-commit.ci
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_URLfromVC_SIGNER_URLIf 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"}}%