<?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 Re: Tokens only valid for 4 hours from app console in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Re-Tokens-only-valid-for-4-hours-from-app-console/m-p/618475#M28464</link>
    <description>&lt;P&gt;Dear Greg-DB,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't get any error messages when initially connecting or reconnecting to the Dropbox. Nor is there a pattern when the reconnection doesn't work. It even happens during working with the app for a longer time when the user wants to store data on Dropbox. It happens on different devices e.g. iPhone 8 and iPhone 12.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a command in swift to to initiate the refresh of the token programmatically?&lt;/P&gt;</description>
    <pubDate>Fri, 26 Aug 2022 09:44:45 GMT</pubDate>
    <dc:creator>gcarl</dc:creator>
    <dc:date>2022-08-26T09:44:45Z</dc:date>
    <item>
      <title>Re: Tokens only valid for 4 hours from app console</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Re-Tokens-only-valid-for-4-hours-from-app-console/m-p/617480#M28440</link>
      <description>&lt;P&gt;Dear greg-DB,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;sorry, but I have to come back to this topic again, since I couldn't solve it in the recent weeks despite all these valuable hints in this forum and the description for the Swift SDK.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm writing an app with Swift and I originally set it up with a long-term token, which was changed by Dropbox in the meantime.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I do the setup in the appDelegate with (dropboxAppKey is the key I created &amp;nbsp;in the Dropbox-portal for my App)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -&amp;gt; Bool {
        UIApplication.shared.registerForRemoteNotifications()
        DropboxClientsManager.setupWithAppKey(dropboxAppKey) 
...
}&lt;/LI-CODE&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;P&gt;&lt;SPAN&gt;and I'm doing the connect as&amp;nbsp;decribed with&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;func connectDropbox() {
        let scopeRequest = ScopeRequest(scopeType: .user, scopes: ["files.content.write", "files.content.read", "account_info.read"], includeGrantedScopes: false)
            DropboxClientsManager.authorizeFromControllerV2(
                UIApplication.shared,
                controller: self,
                loadingStatusDelegate: nil,
                openURL: { (url: URL) -&amp;gt; Void in UIApplication.shared.open(url, options: [:], completionHandler: nil) },
                scopeRequest: scopeRequest
            )
    }
    &lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and as described in appDelegate with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -&amp;gt; Bool {
        let oauthCompletion: DropboxOAuthCompletion = {
          if let authResult = $0 {
              switch authResult {
              case .success:
                  print("Success! User is logged into DropboxClientsManager.")
              case .cancel:
                  print("Authorization flow was manually canceled by user!")
              case .error(_, let description):
                  print("Error: \(String(describing: description))")
              }
          }
        }
        let canHandleUrl = DropboxClientsManager.handleRedirectURL(url, completion: oauthCompletion)
        return canHandleUrl
    }&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;respectively as described in the SDK for the SceneDelegate.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Everything works fine and I can access data from and save data to the Dropbox for a certain while (it seems to be even less than 4 hours) and then out of a sudden the connection is interrupted.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Within my app I check the availability of the dropbox before saving or retrieving data with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;if let client = DropboxClientsManager.authorizedClient {
                         dropboxClient = client
                         dropboxClient!.files.download(path: ... )
                             .response { response, error in
                                 if let response = response {
                                     let _ = response.0
                                     let fileContents = response.1
                                     &amp;lt;code&amp;gt;
                                 } else if let error = error {
                                     switch error as CallError {
                                     case .routeError:
                                        &amp;lt;code&amp;gt;
                                     default:
                                        &amp;lt;code&amp;gt;
                                         return
                                     }
                                 }
                             }
                     }&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unfortunately, I can't manage the described automatic refresh for my app. Is there a certain coding I have to call if the above mentioned availability-check ("if let client = DropboxClientsManager.authorizedClient ") provides nil?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your support&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2022 00:41:53 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Re-Tokens-only-valid-for-4-hours-from-app-console/m-p/617480#M28440</guid>
      <dc:creator>gcarl</dc:creator>
      <dc:date>2022-08-23T00:41:53Z</dc:date>
    </item>
    <item>
      <title>Re: Tokens only valid for 4 hours from app console</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Re-Tokens-only-valid-for-4-hours-from-app-console/m-p/617489#M28441</link>
      <description>&lt;P&gt;Can you elaborate on what you mean when you say "the connection is interrupted"? Do you get a particular error? If so, please share it here. Or, do you mean that DropboxClientsManager.authorizedClient just becomes nil at that point?&lt;/P&gt;</description>
      <pubDate>Mon, 22 Aug 2022 15:57:19 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Re-Tokens-only-valid-for-4-hours-from-app-console/m-p/617489#M28441</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2022-08-22T15:57:19Z</dc:date>
    </item>
    <item>
      <title>Re: Tokens only valid for 4 hours from app console</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Re-Tokens-only-valid-for-4-hours-from-app-console/m-p/617496#M28443</link>
      <description>&lt;P&gt;Dear Greg-DB,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it is the latter one - I get the "nil" as response in the availability check. I understood the whole discussion that this shouldn't be the case and the refresh should happen automatically via the refresh token in the background instead. Is this correct?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the support&lt;/P&gt;</description>
      <pubDate>Mon, 22 Aug 2022 16:18:22 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Re-Tokens-only-valid-for-4-hours-from-app-console/m-p/617496#M28443</guid>
      <dc:creator>gcarl</dc:creator>
      <dc:date>2022-08-22T16:18:22Z</dc:date>
    </item>
    <item>
      <title>Re: Tokens only valid for 4 hours from app console</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Re-Tokens-only-valid-for-4-hours-from-app-console/m-p/617514#M28444</link>
      <description>&lt;P&gt;Thanks for clarifying. That's correct, the refresh process should be handled for you automatically as long as you've processed the authorization flow using authorizeFromControllerV2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Even if you did only have a short-lived access token stored though, or if the refresh process failed and the SDK wasn't able to get a new short-lived access token, you would still have the expired access token stored so you would have a non-nil authorizedClient and should get back a specific error like 'expired_access_token' when attempting a call.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, from your description, with the issue occurring sooner than four hours, and with authorizedClient itself being nil, it sounds like the issue isn't actually with the access token expiration itself. It seems as if the token isn't being persisted successfully. The SDK uses the system's keychain functionality to store and retrieve the tokens.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does the authorizedClient seem to get lost after any particular event, such as when the app (or device) is restarted?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does this happen on multiple different devices? (I've occasionally heard of issues with the keychain not working properly on specific devices.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you perhaps get any error/output during the authorizeFromControllerV2/handleRedirectURL flow?&lt;/P&gt;</description>
      <pubDate>Mon, 22 Aug 2022 17:12:24 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Re-Tokens-only-valid-for-4-hours-from-app-console/m-p/617514#M28444</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2022-08-22T17:12:24Z</dc:date>
    </item>
    <item>
      <title>Re: Tokens only valid for 4 hours from app console</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Re-Tokens-only-valid-for-4-hours-from-app-console/m-p/618475#M28464</link>
      <description>&lt;P&gt;Dear Greg-DB,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't get any error messages when initially connecting or reconnecting to the Dropbox. Nor is there a pattern when the reconnection doesn't work. It even happens during working with the app for a longer time when the user wants to store data on Dropbox. It happens on different devices e.g. iPhone 8 and iPhone 12.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a command in swift to to initiate the refresh of the token programmatically?&lt;/P&gt;</description>
      <pubDate>Fri, 26 Aug 2022 09:44:45 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Re-Tokens-only-valid-for-4-hours-from-app-console/m-p/618475#M28464</guid>
      <dc:creator>gcarl</dc:creator>
      <dc:date>2022-08-26T09:44:45Z</dc:date>
    </item>
    <item>
      <title>Re: Tokens only valid for 4 hours from app console</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Re-Tokens-only-valid-for-4-hours-from-app-console/m-p/618493#M28466</link>
      <description>&lt;P&gt;There is a refreshAccessToken method, but you don't need to call that. (That's used internally, or if you want to switch to a smaller subset of scopes.) The SDK automatically performs the normal refresh process for you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It doesn't sound like that's the issue anyway though, as the local client wouldn't get set to nil if the access token expires. The server would just return an error when an expired access token is used. Also, it doesn't seem like expiration is the issue since you're seeing this occur sooner than four hours after authorization.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you calling anything like unlinkClients, resetClients, or clearStoredAccessToken(s)?&lt;/P&gt;</description>
      <pubDate>Fri, 26 Aug 2022 13:15:33 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Re-Tokens-only-valid-for-4-hours-from-app-console/m-p/618493#M28466</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2022-08-26T13:15:33Z</dc:date>
    </item>
    <item>
      <title>Re: Tokens only valid for 4 hours from app console</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Re-Tokens-only-valid-for-4-hours-from-app-console/m-p/618498#M28467</link>
      <description>&lt;P&gt;Dear greg-DB,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks for your quick replies - highly appreciated.&lt;/P&gt;&lt;P&gt;No, I'm not using&amp;nbsp;&lt;SPAN&gt;unlinkClients, resetClients, or clearStoredAccessToken(s) or something like it. As quoted above, I only do the setup with the DropboxClientsManager.setupWithAppKey() in appDelegate und&amp;nbsp;authorize with the DropboxClientsManager.authorizeFromControllerV2(). After it I only do read and write tasks - all checked with&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;if let client = DropboxClientsManager.authorizedClient {... }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;where sometimes the nil-value is returned, in which cases then the reconnection is initiated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In which cases turns the DropboxClientsManager.authorizedClient to nil? Do I have to handle it differently, when it is nil? Currently I'm calling&amp;nbsp;&lt;SPAN&gt;the DropboxClientsManager.authorizeFromControllerV2() in these cases.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Aug 2022 13:37:32 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Re-Tokens-only-valid-for-4-hours-from-app-console/m-p/618498#M28467</guid>
      <dc:creator>gcarl</dc:creator>
      <dc:date>2022-08-26T13:37:32Z</dc:date>
    </item>
    <item>
      <title>Re: Tokens only valid for 4 hours from app console</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Re-Tokens-only-valid-for-4-hours-from-app-console/m-p/618533#M28468</link>
      <description>&lt;P&gt;The authorizedClient should only be nil if the clients were reset, or if after a relaunch the SDK wasn't able to retrieve the token from the Keychain. There isn't anything else you need to be doing to keep the authorizedClient available. Calling authorizeFromControllerV2 when you don't have an authorizedClient and need to connect to an account is the right procedure. Seeing authorizedClient automatically revert to nil is just unexpected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyway, I don't see anything you're doing wrong here that should cause this, and I can't reproduce the issue here myself. Apologies for the bother, but would you be able to share a small sample project that reproduces the issue so we can investigate here? Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Fri, 26 Aug 2022 15:34:45 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Re-Tokens-only-valid-for-4-hours-from-app-console/m-p/618533#M28468</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2022-08-26T15:34:45Z</dc:date>
    </item>
    <item>
      <title>Re: Tokens only valid for 4 hours from app console</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Re-Tokens-only-valid-for-4-hours-from-app-console/m-p/618551#M28469</link>
      <description>Dear Greg-db,&lt;BR /&gt;&lt;BR /&gt;would it be helpful if I send you a promocode for the AppStore for my app I‘m facing this issue via e-mail?</description>
      <pubDate>Fri, 26 Aug 2022 17:01:17 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Re-Tokens-only-valid-for-4-hours-from-app-console/m-p/618551#M28469</guid>
      <dc:creator>gcarl</dc:creator>
      <dc:date>2022-08-26T17:01:17Z</dc:date>
    </item>
    <item>
      <title>Re: Tokens only valid for 4 hours from app console</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Re-Tokens-only-valid-for-4-hours-from-app-console/m-p/618567#M28472</link>
      <description>&lt;P&gt;That may not be helpful as we wouldn't be able to inspect or debug the code directly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've put together a small sample project using the code snippets you provided &lt;A href="https://www.dropbox.com/s/gw4yvespdqrawfl/test_617480.zip?dl=0" target="_blank"&gt;here&lt;/A&gt;, just filling in the gaps as necessary. It doesn't reproduce the issue for me. (It retains the authorizedClient and can successfully make calls even after more than four hours after authorization.) Could you try it though and see if produces the issue for you?&lt;/P&gt;</description>
      <pubDate>Fri, 26 Aug 2022 19:49:44 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Re-Tokens-only-valid-for-4-hours-from-app-console/m-p/618567#M28472</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2022-08-26T19:49:44Z</dc:date>
    </item>
    <item>
      <title>Re: Tokens only valid for 4 hours from app console</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Re-Tokens-only-valid-for-4-hours-from-app-console/m-p/619918#M28546</link>
      <description>&lt;P&gt;Dear Greg-DB,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tested your test app on different devices and it worked as expected without any problems.&lt;/P&gt;&lt;P&gt;Since the code of your test app is exactly the same I use in my apps except for the Dropbox appkey, the questions is, if the problems are linked with the appkey? I originally registered the apps with a long term token, which was changed automatically meanwhile in course of your initiative of replacing these tokens.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards gcarl&lt;/P&gt;</description>
      <pubDate>Fri, 02 Sep 2022 04:36:21 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Re-Tokens-only-valid-for-4-hours-from-app-console/m-p/619918#M28546</guid>
      <dc:creator>gcarl</dc:creator>
      <dc:date>2022-09-02T04:36:21Z</dc:date>
    </item>
    <item>
      <title>Re: Tokens only valid for 4 hours from app console</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Re-Tokens-only-valid-for-4-hours-from-app-console/m-p/619978#M28553</link>
      <description>&lt;P&gt;There shouldn't be anything unusual about your app key in particular. To check that though, you could try replacing my app key in the sample project with yours and retesting it. Please try that and let me know how it goes.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Sep 2022 12:50:00 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Re-Tokens-only-valid-for-4-hours-from-app-console/m-p/619978#M28553</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2022-09-02T12:50:00Z</dc:date>
    </item>
  </channel>
</rss>

