File Upload in a folder in Assignment

Options
Kwangsub.Ahn9052
Kwangsub.Ahn9052 Posts: 9 🌱
edited November 2022 in Development

I am using below API for file upload. /d2l/api/le/(version)/(orgUnitId)/dropbox/folders/(folderId)/submissions/mysubmissions

 

And for the authentication, I use  ID/Key-based authentication system with my super user account.

 

The issue is that, whenever I upload a file, the file is always under the name of super user account.

Is there a way to create a folder and upload the file there or upload the file under the name of logged in user's name

 

Thanks,

Tagged:

Answers

  • Jordan.Snider3520
    Jordan.Snider3520 Posts: 42
    edited November 2022
    Options

    Hey @Kwangsub Ahn​ ,

     

    The reason your superuser name keeps appear is because of your app is setup. Because you do use a superuser account to make the requests, thats the user account who's context who your app thinks is currently logged in. In order to get a different name in place of the superuser account, you would need your application to authenticate as that user and make the API calls as. Or you can make a user GET request to pull user information and use the user's information in thar request to populate the file name.

  • Joseph.W.983
    Joseph.W.983 Posts: 7
    edited November 2022
    Options

    You can look at https://github.com/Brightspace/oauth2.0-client-example to see how to obtain a user token.

  • Kwangsub.Ahn9052
    Kwangsub.Ahn9052 Posts: 9 🌱
    edited November 2022
    Options

    @Jordan Snider​ Thank you for explanation.

     

    But biggest concern was how to authenticate as that user and make the API calls. I only know super user's id and key so I can make the API calls. If I have to make the API calls with the user, how can I get the User Id & User key of the specific user?

     

  • Kwangsub.Ahn9052
    Kwangsub.Ahn9052 Posts: 9 🌱
    edited November 2022
    Options

    What I am trying to do is.. 1. Admin will create a page in Content where each user can upload a file. 2. Each will access to the page and upload a file (The file will be sent to our application). 3. Our application calls File Upload request to D2L to save the file in Assignment folder. 4. each file uploaded in Assignment folder shouldn't be under the name of Super User.

     

    My problem is #4, I don't know how to change the name. Whenever I upload a file through Valency API, it's using super user's name.

  • Jordan.Snider3520
    Jordan.Snider3520 Posts: 42
    edited November 2022
    Options

    To get the User Id/Key pair you would need to follow the API workflow to fully authenticate as that user and move away from your superuser session. There is no workaround to aquiring an auth token for a user in our API workflows. Student user accounts typically do have the permission to upload to an assignment folder. Perhaps you can move away from the superuser of your application?

  • Kwangsub.Ahn9052
    Kwangsub.Ahn9052 Posts: 9 🌱
    edited November 2022
    Options

    Could you provide me URL for the API workflow?

  • Jordan.Snider3520
    Jordan.Snider3520 Posts: 42
    edited November 2022
    Options

    Certainly, it is just the base auth workflow of our APIs: http://docs.valence.desire2learn.com/basic/firstlist.html#authenticate-with-your-lms

     

    We provide code samples and SDKs to help you get started!