<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Using Refresh Token in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Using-Refresh-Token/m-p/619194#M28515</link>
    <description>&lt;P&gt;Currently I am trying to migrate our application to the new refresh token system&lt;/P&gt;
&lt;P&gt;I am getting my Refresh token and my ExpiresAt values, and saving that data on the database,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if the ExpiresAt value has already pass I am creating my object this way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt; dbx = new DropboxClient(settings.RefreshToken, appKey, appSecret);&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and using that new object for my resquest, but in my view I am still getting the message:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Failed to access a remote cloud service&lt;BR /&gt;StatusCode: Unauthorized&lt;BR /&gt;Request result: {"error_summary": "expired_access_token/.", "error": {".tag": "expired_access_token"}}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where in c# I have to sent my refresh token value so it can keep the token alive when I need it?&lt;/P&gt;</description>
    <pubDate>Tue, 06 Sep 2022 09:53:08 GMT</pubDate>
    <dc:creator>CTO1</dc:creator>
    <dc:date>2022-09-06T09:53:08Z</dc:date>
    <item>
      <title>Using Refresh Token</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Using-Refresh-Token/m-p/619194#M28515</link>
      <description>&lt;P&gt;Currently I am trying to migrate our application to the new refresh token system&lt;/P&gt;
&lt;P&gt;I am getting my Refresh token and my ExpiresAt values, and saving that data on the database,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if the ExpiresAt value has already pass I am creating my object this way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt; dbx = new DropboxClient(settings.RefreshToken, appKey, appSecret);&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and using that new object for my resquest, but in my view I am still getting the message:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Failed to access a remote cloud service&lt;BR /&gt;StatusCode: Unauthorized&lt;BR /&gt;Request result: {"error_summary": "expired_access_token/.", "error": {".tag": "expired_access_token"}}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where in c# I have to sent my refresh token value so it can keep the token alive when I need it?&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2022 09:53:08 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Using-Refresh-Token/m-p/619194#M28515</guid>
      <dc:creator>CTO1</dc:creator>
      <dc:date>2022-09-06T09:53:08Z</dc:date>
    </item>
    <item>
      <title>Re: Using Refresh Token</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Using-Refresh-Token/m-p/619241#M28517</link>
      <description>&lt;P&gt;Building a DropboxClient with the refresh token, app key, and app secret as you've shown here is correct and valid. Are you sure that is the specific DropboxClient object you're using when you're getting that 'expired_access_token' error? I just tried it and it is working for me with my own values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that an 'ExpiresAt' value would be referring to a specific access token (not a refresh token). When building a client with the refresh token and app key/secret like that, the client won't even have an access token anyway, so it will automatically get a new valid one. That being the case, you don't actually need to store and supply the access token and expiration information to begin with, since you can always just supply the refresh token.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2022 18:32:50 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Using-Refresh-Token/m-p/619241#M28517</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2022-08-30T18:32:50Z</dc:date>
    </item>
    <item>
      <title>Re: Using Refresh Token</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Using-Refresh-Token/m-p/619524#M28530</link>
      <description>&lt;P&gt;here is where I am getting my model, the dbxService is where I send the refreshToken value as show in the previus message&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public async Task&amp;lt;FileManagerViewModel&amp;gt; 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;
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;but here&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;provider.AccessTokenValue = Backoffice.Encryptor.Decrypt(dropBoxsettings.AuthToken);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I ma getting a message that says that AccessTokenValue is obsolete, I am unable to find any example of how to use:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CTO1_0-1661961944175.png" style="width: 400px;"&gt;&lt;img src="https://www.dropboxforum.com/t5/image/serverpage/image-id/31379i69DE21CED38FD68F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="CTO1_0-1661961944175.png" alt="CTO1_0-1661961944175.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;can you tell me where is wrong the code please?&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2022 16:06:23 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Using-Refresh-Token/m-p/619524#M28530</guid>
      <dc:creator>CTO1</dc:creator>
      <dc:date>2022-08-31T16:06:23Z</dc:date>
    </item>
    <item>
      <title>Re: Using Refresh Token</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Using-Refresh-Token/m-p/619543#M28532</link>
      <description>&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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).&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2022 17:11:41 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Using-Refresh-Token/m-p/619543#M28532</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2022-08-31T17:11:41Z</dc:date>
    </item>
    <item>
      <title>Re: Using Refresh Token</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Using-Refresh-Token/m-p/619544#M28533</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1568182"&gt;@CTO1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;...&lt;/P&gt;&lt;PRE&gt;provider.AccessTokenValue = Backoffice.Encryptor.Decrypt(dropBoxsettings.AuthToken);&lt;/PRE&gt;&lt;P&gt;I ma getting a message that says that AccessTokenValue is obsolete, I am unable to find any example of how to use:&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Hi &lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1568182"&gt;@CTO1&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;First of all, why do you need access token at all??? Clarify to yourself it! 🤷 You already have a client. Why don't you use it? &lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@41457EF40051AFF130FDBFE21B496926/emoticons/1f609.png" alt=":winking_face:" title=":winking_face:" /&gt;&lt;/P&gt;&lt;P&gt;Next, you are using the former (got at authorization time) access token!!! - not the actualized one. &lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@D88F213CAFB196B6AB70612B08AD9D31/emoticons/1f601.png" alt=":beaming_face_with_smiling_eyes:" title=":beaming_face_with_smiling_eyes:" /&gt; Be more careful! After some time (at most 4 hours) every access token expires. That's why you are getting the posted error message. &lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@41457EF40051AFF130FDBFE21B496926/emoticons/1f609.png" alt=":winking_face:" title=":winking_face:" /&gt;&lt;/P&gt;&lt;P&gt;Hope this clarifies matter.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2022 17:15:15 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Using-Refresh-Token/m-p/619544#M28533</guid>
      <dc:creator>Здравко</dc:creator>
      <dc:date>2022-08-31T17:15:15Z</dc:date>
    </item>
    <item>
      <title>Re: Using Refresh Token</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Using-Refresh-Token/m-p/619666#M28538</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/10"&gt;@Greg-DB&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;Building a DropboxClient with the refresh token, app key, and app secret as you've shown here is correct and valid. Are you sure that is the specific DropboxClient object you're using when you're getting that 'expired_access_token' error? I just tried it and it is working for me with my own values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note that an 'ExpiresAt' value would be referring to a specific access token (not a refresh token). When building a client with the refresh token and app key/secret like that, the client won't even have an access token anyway, so it will automatically get a new valid one. That being the case, you don't actually need to store and supply the access token and expiration information to begin with, since you can always just supply the refresh token.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Thanks Greg for replaying my question&lt;/P&gt;&lt;P&gt;we are using a third party tool in our UI to navigate our dropbox folders and we send our AuthToken.&lt;/P&gt;&lt;P&gt;we don't need it for the dropbox client but is there a way to get the new AuthToken after we use RefreshToken?&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2022 01:52:01 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Using-Refresh-Token/m-p/619666#M28538</guid>
      <dc:creator>CTO1</dc:creator>
      <dc:date>2022-09-01T01:52:01Z</dc:date>
    </item>
    <item>
      <title>Re: Using Refresh Token</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Using-Refresh-Token/m-p/619766#M28540</link>
      <description>&lt;P&gt;No, the official Dropbox .NET SDK does not offer a way to retrieve the latest short-lived access token that it has, but I'll pass this along as a feature request. I can't promise if or when that might be implemented though.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2022 12:54:56 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Using-Refresh-Token/m-p/619766#M28540</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2022-09-01T12:54:56Z</dc:date>
    </item>
    <item>
      <title>Re: Using Refresh Token</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Using-Refresh-Token/m-p/619784#M28543</link>
      <description>&lt;P&gt;Easy workaround can be a parallel instantiation of &lt;A href="https://github.com/dropbox/dropbox-sdk-dotnet/blob/main/dropbox-sdk-dotnet/Dropbox.Api/DropboxRequestHandler.cs" target="_blank" rel="noopener"&gt;DropboxRequestHandler&lt;/A&gt; class. Big part of the stuff inside, not closely related to refreshing, can be wipe out. Classes, fields and methods visibility should be changed, so be accessible outside. Using &lt;A title="Uses the refresh token to obtain a new access token" href="https://github.com/dropbox/dropbox-sdk-dotnet/blob/main/dropbox-sdk-dotnet/Dropbox.Api/DropboxRequestHandler.cs#L246" target="_blank" rel="noopener"&gt;RefreshAccessToken&lt;/A&gt; method (already public) new/actual refresh token will be received. The received token can be accessed through &lt;A title="Gets or sets the OAuth2 token" href="https://github.com/dropbox/dropbox-sdk-dotnet/blob/main/dropbox-sdk-dotnet/Dropbox.Api/DropboxRequestHandler.cs#L1011" target="_blank" rel="noopener"&gt;OAuth2AccessToken&lt;/A&gt; within the &lt;A title="The configuration options for dropbox client" href="https://github.com/dropbox/dropbox-sdk-dotnet/blob/main/dropbox-sdk-dotnet/Dropbox.Api/DropboxRequestHandler.cs#L64" target="_blank" rel="noopener"&gt;options&lt;/A&gt; field. That's it - just a copy of existing file (and filtered) from SDK to the application. &lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@41457EF40051AFF130FDBFE21B496926/emoticons/1f609.png" alt=":winking_face:" title=":winking_face:" /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2022 14:42:13 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Using-Refresh-Token/m-p/619784#M28543</guid>
      <dc:creator>Здравко</dc:creator>
      <dc:date>2022-09-01T14:42:13Z</dc:date>
    </item>
  </channel>
</rss>

