You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
CTO1
3 years agoExplorer | Level 3
Using Refresh Token
Currently I am trying to migrate our application to the new refresh token system
I am getting my Refresh token and my ExpiresAt values, and saving that data on the database,
if the ExpiresAt ...
CTO1
Explorer | Level 3
here is where I am getting my model, the dbxService is where I send the refreshToken value as show in the previus message
public async Task<FileManagerViewModel> GetDropboxViewModel(Panther.Views.Attachment.IndexViewModel gridViewModel, IIdentityService identityService)
{
var dbxViewModel = new FileManagerViewModel();
dbxViewModel.Type = FileManagerProviderType.Dropbox;
Project project = null;
var dropBoxsettings = await _unitOfWork.DropBoxSettingsRepository.GetSettingsByTenantId(identityService.Tenant.Id).FirstAsync().ConfigureAwait(false);
var path = "/MyCompany";
MyCompanyLogger.Log(MyCompanyLogLevel.Info, "BlobRepository: GetDropboxViewModel", $"GridViewModel: {Newtonsoft.Json.JsonConvert.SerializeObject(gridViewModel)}");
try
{
var dbxService = new Panther.Services.DropboxService(dropBoxsettings);
FolderMetadata folder = null;
if (gridViewModel.AccountGuid.HasValue)
{
var account = await _unitOfWork.AccountRepository.GetAccount(identityService, gridViewModel.AccountGuid.Value, AccessLevelAction.Details).FirstAsync().ConfigureAwait(false);
folder = await dbxService.GetFolder(account.DropboxFolderId, account.NameAndNumber);
if (account.DropboxFolderId != folder.Id)
{
account.DropboxFolderId = folder.Id;
await _unitOfWork.AccountRepository.InsertOrUpdateAndSaveAsync(account).ConfigureAwait(false);
MyCompanyLogger.Log(MyCompanyLogLevel.Info, "BlobRepository: GetDropboxViewModel", $"Account updated Dropbox folder Id: {account.DropboxFolderId}");
}
path = folder.PathLower;
}
if (gridViewModel.ProjectGuid.HasValue)
{
project = await _unitOfWork.ProjectRepository.GetProject(identityService, gridViewModel.ProjectGuid.Value, AccessLevelAction.Details).FirstAsync().ConfigureAwait(false);
folder = await dbxService.GetFolder(project.DropboxFolderId, project.NameAndNumber, project.Account.DropboxFolderId, project.Account.NameAndNumber);
if (project.DropboxFolderId != folder.Id)
{
project.DropboxFolderId = folder.Id;
await _unitOfWork.ProjectRepository.InsertOrUpdateAndSaveAsync(project).ConfigureAwait(false);
MyCompanyLogger.Log(MyCompanyLogLevel.Info, "BlobRepository: GetDropboxViewModel", $"Project updated Dropbox folder Id: {project.DropboxFolderId}");
}
path = folder.PathLower;
}
var provider = new DropboxFileSystemProvider(path);
DevExpress.Web.AccountManager.RegisterDropbox("Dropbox1", "AccessTokenValue1");
provider.AccessTokenValue = Backoffice.Encryptor.Decrypt(dropBoxsettings.AuthToken);
provider.AccountName = Backoffice.Encryptor.Decrypt(dropBoxsettings.AuthToken);
dbxViewModel.FileSystemProvider = provider;
dbxViewModel.IsAllowCreate = HasAccess(FilePermissions.Create, identityService, project);
dbxViewModel.IsAllowDelete = HasAccess(FilePermissions.Delete, identityService);
dbxViewModel.IsAllowEdit = HasAccess(FilePermissions.Delete, identityService);
dbxViewModel.IsAllowDownload = HasAccess(FilePermissions.Download, identityService);
}
catch (Exception ex)
{
Backoffice.ErrorHelper.LogErrorManually(ex);
MyCompanyLogger.Log(MyCompanyLogLevel.Error, "BlobRepository: GetDropboxViewModel exception", ex);
}
return dbxViewModel;
}
but here
provider.AccessTokenValue = Backoffice.Encryptor.Decrypt(dropBoxsettings.AuthToken);
I ma getting a message that says that AccessTokenValue is obsolete, I am unable to find any example of how to use:
can you tell me where is wrong the code please?
Greg-DB
3 years agoDropbox Staff
In this code I see references to "Panther.Services.DropboxService" and "DropboxFileSystemProvider", which are not classes/types written by Dropbox, so unfortunately I cannot offer support for those. You'll need to refer to the documentation/support resources for those third party objects.
Also, I don't see it referencing a refresh token anyway, just an access token. I don't know what's in your "dropBoxsettings", but on "provider" itself at least it looks like you're only setting an access token, not a refresh token.
New Dropbox access tokens are short-lived and are only valid for several hours, so if you're only loading a previously retrieved access token you will get the 'expired_access_token' starting a few hours after it was retrieved. The refresh tokens don't expire by default and can and should be re-used. The official Dropbox .NET SDK can accept just the refresh token, app key, and app secret so you don't even need to store an access token to use that, but I can't offer guidance on how to use those third party objects in a similar manner (or if they are even written to support refresh tokens at all).
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,915 PostsLatest Activity: 2 days agoIf 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!