Forum Discussion

chakmangoo's avatar
chakmangoo
Explorer | Level 4
2 years ago

How to authenticate and stream a video file

Hello,

 

Question: How can I authenticate and stream a video file using api? 

 

Context: I am working on a tool that should authenticate first to access a user file (I understand the token-ing process) and once I have access to a video file I want to stream it using C# dropbox api.

 

Thanks

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    For information on how to use the authorization process, refer to the OAuth Guide and authorization documentation.

     

    If you use the official Dropbox API v2 .NET SDK from C#, you do not need to implement all of the code for this process yourself. The SDK will do most of the work for you. You can find examples of using this here. For instance, you can find an example of getting and using a refresh token in the OauthBasic example (non-PKCE, meant for server-side apps) as well as in the OAuthPKCE example (PKCE, meant for client-side apps). 

     

    Using the Dropbox .NET SDK, you have a few options for accessing file data, such as for a video file. For example, you can call DownloadAsync to get the file data as a Stream. Or, you can call GetTemporaryLinkAsync to get a link to the file data.

     

    In case you don't use the Dropbox .NET SDK, those are /2/files/download and /2/files/get_temporary_link respectively on the API itself.

    • chakmangoo's avatar
      chakmangoo
      Explorer | Level 4

      Thanks you very much, Greg!

       

      I follow-up question with some testing.

       

      curl -X POST https://api.dropboxapi.com/2/file_requests/list_v2 --header "Authorization: Bearer <bearer_token>" --data "{\"limit\":1000}" --header "Dropbox-API-Select-User <user_token>

       

      Upon trying a simple curl command in terminal to make sure that I get a valid response (list of files) from dropbox server, I get this response: 

       

      curl: (52) Empty reply from server

       

      I have the files in the folder and token are not expired as well. 

      Any idea what could be wrong?

      • Здравко's avatar
        Здравко
        Legendary | Level 20

        chakmangoo wrote:

        ...

        I have the files in the folder and token are not expired as well. 

        Any idea what could be wrong?


        Hi chakmangoo,

        I believe you about your files and probably there is nothing wrong with them. When you list them you will get back correct list, I believe too. 😉

        In meantime, what do you see here? 🧐 Does it match to the result you got above? 🤔 If not, try play with that what you see there and post the details.

        😁Hope this clarifies matter. 🙂

         

        PS: When you post some example (either command line or code snippet), post a complete example letting reproduction of the possible issue and only mask private info (codes, tokens, etc.). Your command line end is missing above, so it's not clear why you got that result (likely something mistyped, like separators). There is some more wrong thing (in addition to wrong endpoint selection). Try to prototype endpoints calls here and here. Good luck.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,950 PostsLatest Activity: 15 hours ago
352 Following

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!