Adding Course Content through API calls

Options

I'm following the https://community.d2l.com/brightspace/kb/articles/1529-adding-course-content using Postman. I've followed most of the tutorials on the site with success with this one exception. When I run the API call, according to the directions, I get a { Errors: [ {Message: "Insufficient scope to call API.Required: content:modules:read"} ] }. How can fix this?

Tagged:

Answers

  • Viktor.H.147
    Options

    The application making that API call needs to:

    • be registered as wanting to ask for the content:modules:read scope
    • ask for that scope when requesting an OAuth2 access token
    • actually be given an access token that does have this scope (if the app meets the first two bullets, this bullet should take care of itself)
  • Andrea.B.236
    Andrea.B.236 Posts: 185 admin
    Options

    Hi @Justin.Bamberg3364 ,

    Thank you for reaching out to the Brightspace Community!

    The reason you would receive this error is due to the API call needing the "scope" of the call and needing access to that scope.

    We have documentation on API Authentication Best Practices that may be useful on defining and calling the scope of your API call.

  • Justin.B.253
    Justin.B.253 Posts: 12 🌱
    Options

    @Viktor Haa62 and @Andrea Bla691 Thank you for that information, I'm new to this and just started playing last night. I created the new authorization and added the correct scope but I'm now getting this error message when I click Get New Access Token.

    {"error":"invalid_scope","error_description":"Client is not authorized to request the scope content:modules:read"}

    If I'm the administrator to the system, shouldn't I be authorized?

    Thank you,

    Justin Bamberg

  • Joshua.V.999
    Options

    Justin,

    Can you confirm that the application whose OAuth credentials you are using to make these calls also has the above scope added? You can find this information by:

    • Navigate to the admin "cog"
    • Locate and click the "Manage Extensibility" item
    • Locate and click the "OAuth 2.0" tab
    • Locate and edit your application
    • Ensure the scope field includes the scope above (content:modules:read), and any other relevant scopes

    Follow Viktor's steps again and hopefully, you are able to generate a valid token.

    Cheers,

  • Justin.B.253
    Justin.B.253 Posts: 12 🌱
    Options

    @Joshua Vie797 Thank you, that worked. I didn't know that I could add multiple scopes in the application on D2L. I appreciate your help as I continue to learn.