My client has 100,000s of images stored in dropbox. The goal is to have some database information displayed alongside any one of the images.
From what I understand, I would need need to use a service account or OAuth2 so that the visiting user never knows anything about the file location and the only access is via the owners dropbox authority via the app.
I have tried to follow the online instructions but they are varied and change from site to site and over the years.
My first step was to load this url - https://www.dropbox.com/oauth2/authorize?client_id=&token_access_type=offline&response_type=code
This returned a Code. I placed this code the below .net 9 Blazor app but I cannot get past Bad Request
refreshToken = the code I got from the above?
public async Task<string> RefreshAccessTokenAsync(string refreshToken)
{
var client = _httpClientFactory.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.dropbox.com/oauth2/token")
{
Content = new FormUrlEncodedContent(new Dictionary<string, string>
{
{ "grant_type", "refresh_token" },
{ "refresh_token", refreshToken },
{ "client_id", "xxxx" },
{ "client_secret", "xxxx" }
})
};
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
var json = await response.Content.ReadAsStringAsync();
var tokenResponse = JsonSerializer.Deserialize<JsonElement>(json);
return tokenResponse.GetProperty("access_token").GetString();
}
Are there any step by step examples that work to do the above in 2025? I'm really banging my head against the wall here.