Thanks for the quick reply, Chris! I really appreciate the guidance!
This project is not intended for resale or distribution. It was developed internally at the request of one of our school directors.
I probably wasn’t clear in my original post: I’m specifically trying to avoid implementing a full OAuth flow. The script is being loaded as a Theme script, and it runs in the context of the logged-in user. So far, I’ve been able to successfully retrieve data using fetch()calls without an authorization header, for example, I can read outcome rollups, user info, rubric definitions, etc.
The blocker I’m running into is when trying to perform PUT requests, such as updating a rubric score using the rubric_assessment parameter. These requests only succeed if I manually include an access token in the Authorization header. If I remove the authorization header, the request fails, even though the user running the script is a teacher with appropriate grading permissions in the course.
I had hoped that, since data retrieval worked without tokens, writing data might as well, but it appears PUT operations require explicit authentication even within a Theme script.
Let me know if this aligns with your understanding, or if I’m overlooking an alternate approach.
```
async function submitRubricScore(courseId, assignmentId, userId, criterionId, score) {
const payload = {
rubric_assessment: {
[criterionId.toString()]: {
points: score,
comments: "Auto-calculated average mastery score"
}
}
};
console.log("Submitting rubric score for user", userId, payload);
const response = await fetch(`/api/v1/courses/${courseId}/assignments/${assignmentId}/submissions/${userId}`, {
method: "PUT",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer myToken`// works when this line is included, but fails if it is removed
},
body: JSON.stringify(payload)
});
if (!response.ok) {
const errorText = await response.text();
console.error("Submission failed for user", userId, "→", errorText);
throw new Error(`Failed to update user ${userId}: ${errorText}`);
}
console.log("Score submitted successfully for user", userId);
}