Start 2025 on time and up to date. Seamlessly integrate your calendars into Dropbox with these simple steps.

Forum Discussion

manishkanwaria's avatar
manishkanwaria
New member | Level 2
2 years ago

Generate access token without client interaction using Dropbox SDK (C# Api Project)

Hi Folks,   I have a C# API project which has a service that downloads video assets from different sources, i.e., Azure Blob, AMS, and other client environments. The new client came in with Dro...
  • Greg-DB's avatar
    2 years ago

    If you need long-term access, you'll need to use the OAuth app authorization flow, but this only needs to be done once per account. It is not possible to fully automate the OAuth process where the user chooses to authorize the app and the app then receives the resulting access token and optional refresh token. This needs to be done manually by the user at least once.
     
    If your app needs to maintain long-term access without the user manually re-authorizing it repeatedly, the app should request "offline" access so that it gets a refresh token. The refresh token doesn't expire and can be stored and used repeatedly to get new short-lived access tokens whenever needed, without the user manually reauthorizing the app.
     
    You can find more information in the OAuth Guide and authorization documentation. There's a basic outline of processing this flow in this blog post which may serve as a useful example. 

     

    When you use the official Dropbox API v2 .NET SDK, you do not need to implement all of the code for the OAuth flow yourself. The SDK will do most of the work for you. You can find examples of using this here. If this is only for your own account, you can also opt to perform the OAuth app authorization flow manually once, e.g., as shown in the post linked in my previous paragraph, and plug that in to the .NET SDK. The SDK will handle the refresh process for you when you supply the necessary credentials: the refresh token, app key, and if not using PKCE, app secret.