<?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 API session expiry? in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/API-session-expiry/m-p/129838#M3765</link>
    <description>&lt;P&gt;Hi everyone,&lt;/P&gt;
&lt;P&gt;I'm in the process of creating a Python app which will run on my Raspberry Pi to&amp;nbsp;allow me to control a webcam via Dropbox. I have created an app and generated an access token. In my program, I have the following general structure:&lt;/P&gt;
&lt;P&gt;if __name__ == '__main__':&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="pln"&gt;&amp;nbsp; &amp;nbsp; dbx &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; dropbox&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="typ"&gt;Dropbox&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;('MY&lt;/SPAN&gt;&lt;SPAN class="str"&gt;_ACCESS_TOKEN'&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="pun"&gt;&amp;nbsp; &amp;nbsp; while True:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="pun"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if poll_parameter('imagerequest') == 1:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="pun"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print 'Image requested'&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="pun"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ## Image capture code here&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="pun"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; reset_parameter('imagerequest')&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="pun"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if poll_parameter('exitprogram') == 1:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="pun"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print 'Exit requested'&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="pun"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; reset_parameter('exitprogram')&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="pun"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="pun"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; time.sleep(poll_parameter('delay'))&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="pun"&gt;So, you can see that the program creates a&amp;nbsp;&lt;SPAN class="pln"&gt;dropbox&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="typ"&gt;Dropbox() session when it first opens, and then enters a loop where it polls certain parameters which are stored as files in the app's folder on Dropbox. Note that the&amp;nbsp;poll_parameter() and&amp;nbsp;reset_parameter() functions use the files_search() and files_move() API functions to search and rename the parameter files as necessary.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="pun"&gt;&lt;SPAN class="typ"&gt;So, I started the program running today when I left for work, and I was able to command it for a few hours and it was taking/uploading images fine, but then it stopped responding. I think this is because the dropbox.Dropbox session may have expired. Does this happen after a certain time interval? How can I ensure that my app can continue to stay connected to Dropbox for as long as I want to use it (possibly weeks at a time)?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="pun"&gt;&lt;SPAN class="typ"&gt;Perhaps if I put my&amp;nbsp;&lt;SPAN class="pln"&gt;dbx &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; dropbox&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="typ"&gt;Dropbox&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;('MY&lt;/SPAN&gt;&lt;SPAN class="str"&gt;_ACCESS_TOKEN'&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;) line at the beginning of every loop, instead of just once at the very beginning of the program?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="pun"&gt;&lt;SPAN class="typ"&gt;&lt;SPAN class="pun"&gt;I also went into my app settings on Dropbox, and my Generated Access Token has disappeared (it just shows the 'Generate' button again). Is this because I left my app running? Why would this delete my access token?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Thanks a lot for the help, I'd love to get this little project off the ground, to the point where it will work for weeks on end so I can remotely monitor my webcams on holiday!&lt;/P&gt;</description>
    <pubDate>Wed, 29 May 2019 09:36:16 GMT</pubDate>
    <dc:creator>George K.23</dc:creator>
    <dc:date>2019-05-29T09:36:16Z</dc:date>
    <item>
      <title>API session expiry?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/API-session-expiry/m-p/129838#M3765</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;
&lt;P&gt;I'm in the process of creating a Python app which will run on my Raspberry Pi to&amp;nbsp;allow me to control a webcam via Dropbox. I have created an app and generated an access token. In my program, I have the following general structure:&lt;/P&gt;
&lt;P&gt;if __name__ == '__main__':&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="pln"&gt;&amp;nbsp; &amp;nbsp; dbx &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; dropbox&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="typ"&gt;Dropbox&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;('MY&lt;/SPAN&gt;&lt;SPAN class="str"&gt;_ACCESS_TOKEN'&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="pun"&gt;&amp;nbsp; &amp;nbsp; while True:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="pun"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if poll_parameter('imagerequest') == 1:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="pun"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print 'Image requested'&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="pun"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ## Image capture code here&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="pun"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; reset_parameter('imagerequest')&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="pun"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if poll_parameter('exitprogram') == 1:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="pun"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print 'Exit requested'&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="pun"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; reset_parameter('exitprogram')&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="pun"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="pun"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; time.sleep(poll_parameter('delay'))&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="pun"&gt;So, you can see that the program creates a&amp;nbsp;&lt;SPAN class="pln"&gt;dropbox&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="typ"&gt;Dropbox() session when it first opens, and then enters a loop where it polls certain parameters which are stored as files in the app's folder on Dropbox. Note that the&amp;nbsp;poll_parameter() and&amp;nbsp;reset_parameter() functions use the files_search() and files_move() API functions to search and rename the parameter files as necessary.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="pun"&gt;&lt;SPAN class="typ"&gt;So, I started the program running today when I left for work, and I was able to command it for a few hours and it was taking/uploading images fine, but then it stopped responding. I think this is because the dropbox.Dropbox session may have expired. Does this happen after a certain time interval? How can I ensure that my app can continue to stay connected to Dropbox for as long as I want to use it (possibly weeks at a time)?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="pun"&gt;&lt;SPAN class="typ"&gt;Perhaps if I put my&amp;nbsp;&lt;SPAN class="pln"&gt;dbx &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; dropbox&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="typ"&gt;Dropbox&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;('MY&lt;/SPAN&gt;&lt;SPAN class="str"&gt;_ACCESS_TOKEN'&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;) line at the beginning of every loop, instead of just once at the very beginning of the program?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="pun"&gt;&lt;SPAN class="typ"&gt;&lt;SPAN class="pun"&gt;I also went into my app settings on Dropbox, and my Generated Access Token has disappeared (it just shows the 'Generate' button again). Is this because I left my app running? Why would this delete my access token?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Thanks a lot for the help, I'd love to get this little project off the ground, to the point where it will work for weeks on end so I can remotely monitor my webcams on holiday!&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 09:36:16 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/API-session-expiry/m-p/129838#M3765</guid>
      <dc:creator>George K.23</dc:creator>
      <dc:date>2019-05-29T09:36:16Z</dc:date>
    </item>
    <item>
      <title>Re: API session expiry?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/API-session-expiry/m-p/129839#M3766</link>
      <description>&lt;P&gt;These sessions don't expire, nor do the access tokens themselves. (Note that access tokens can be explicitly revoked though, e.g.,via&amp;nbsp;&lt;A href="https://www.dropbox.com/account/security" rel="nofollow noreferrer"&gt;https://www.dropbox.com/account/security&lt;/A&gt; .) Further, the App Console lets you generate an access token for your account and app, but it will only show you that token when you generate it. If you return to or reload that page, the previously generated token won't still be showing. Generating another won't revoke the first one though.&lt;/P&gt;
&lt;P&gt;Anyway&amp;nbsp;it sounds like at a certain point, some&amp;nbsp;Dropbox API calls stopped returning the result you expected, or they started failing. So, to investigate this issue, can you share the error/output you got from the app when it started failing? The corresponding code may also be helpful.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Feb 2016 02:19:29 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/API-session-expiry/m-p/129839#M3766</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2016-02-02T02:19:29Z</dc:date>
    </item>
    <item>
      <title>Re: API session expiry?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/API-session-expiry/m-p/129840#M3767</link>
      <description>&lt;P&gt;Hi, thanks for the reply!&lt;/P&gt;
&lt;P&gt;I found that my program terminated with the following error:&lt;/P&gt;
&lt;P&gt;---&lt;/P&gt;
&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt; File "DropCamScript.py", line 29, in &amp;lt;module&amp;gt;&lt;BR /&gt; if poll_cam_parameter(main_dbx, 'imagerequest') == 1:&lt;BR /&gt; File "DropCamScript.py", line 9, in poll_cam_parameter&lt;BR /&gt; sch = dbx.files_search('', param + '=', 0, 1)&lt;BR /&gt; File "/usr/local/lib/python2.7/dist-packages/dropbox/base.py", line 436, in files_search&lt;BR /&gt; None)&lt;BR /&gt; File "/usr/local/lib/python2.7/dist-packages/dropbox/dropbox.py", line 175, in request&lt;BR /&gt; request_binary)&lt;BR /&gt; File "/usr/local/lib/python2.7/dist-packages/dropbox/dropbox.py", line 256, in request_json_string_with_retry&lt;BR /&gt; request_binary)&lt;BR /&gt; File "/usr/local/lib/python2.7/dist-packages/dropbox/dropbox.py", line 316, in request_json_string&lt;BR /&gt; verify=True,&lt;BR /&gt; File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 511, in post&lt;BR /&gt; return self.request('POST', url, data=data, json=json, **kwargs)&lt;BR /&gt; File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 468, in request&lt;BR /&gt; resp = self.send(prep, **send_kwargs)&lt;BR /&gt; File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 576, in send&lt;BR /&gt; r = adapter.send(request, **kwargs)&lt;BR /&gt; File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 426, in send&lt;BR /&gt; raise ConnectionError(err, request=request)&lt;BR /&gt;requests.exceptions.ConnectionError: ('Connection aborted.', BadStatusLine("''",))&lt;/P&gt;
&lt;P&gt;---&lt;/P&gt;
&lt;P&gt;The code is basically as I posted it in the first post (with the addition of some Pygame code to capture from the camera). The only Dropbox functions I use are:&lt;/P&gt;
&lt;P&gt;- dropbox.Dropbox()&lt;/P&gt;
&lt;P&gt;[once, at the beginning of the program, using my previously generated access token]&lt;/P&gt;
&lt;P&gt;- files_search()&lt;/P&gt;
&lt;P&gt;[In my main loop (structure visible in first post), I search the app's dropbox folder for files with different names, and then extract the numbers from these filenames to tell the program what to do. This function appears to have produced the above error. Also, I manually edit the filenames via dropbox to instruct the program to take a picture, wait a certain time between loop iterations, or to exit the loop. Perhaps it's my manual intervention interfering with the files_search() function that caused something strange to happen?]&lt;/P&gt;
&lt;P&gt;-&amp;nbsp;files_move() [I use this to rename files from their current filename to a new filename which contains a specified numeric value. For example, if the program finds a file called 'imagerequest=1', it will use the files_move() function to rename it to 'imagerequest=0']&lt;/P&gt;
&lt;P&gt;...and that's pretty much it! I don't have any exception handling in the program yet, which is why it stopped responding to my dropbox commands when it ran into this issue. Does the error stack provide any guidance?&lt;/P&gt;
&lt;P&gt;Thanks a lot for the help!&lt;/P&gt;</description>
      <pubDate>Tue, 02 Feb 2016 04:36:56 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/API-session-expiry/m-p/129840#M3767</guid>
      <dc:creator>George K.23</dc:creator>
      <dc:date>2016-02-02T04:36:56Z</dc:date>
    </item>
    <item>
      <title>Re: API session expiry?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/API-session-expiry/m-p/129841#M3768</link>
      <description>&lt;P&gt;Thanks! The&amp;nbsp;ConnectionError&amp;nbsp;error can be caused by a number of different things, but it is just indicating there was an issue with the HTTPS connection for the API call, e.g., to due to network issues on your side, or transient server issues on our side. In any case, the right thing to do is just implement some automatic retrying to handle connection issues like this.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Feb 2016 05:03:03 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/API-session-expiry/m-p/129841#M3768</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2016-02-02T05:03:03Z</dc:date>
    </item>
    <item>
      <title>Re: API session expiry?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/API-session-expiry/m-p/129842#M3769</link>
      <description>&lt;P&gt;OK, cool - yeah I guess you can't always guarantee the internet will cooperate! I've added simple exception handling to all my dropbox calls so that at least the program won't terminate. Do you think I have to&amp;nbsp;re-create the dropbox.Dropbox('ACCESS_TOKEN') object in the event of a network exception, or will I be OK to just re-try the search/move functions next time round in the loop?&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 02 Feb 2016 05:13:35 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/API-session-expiry/m-p/129842#M3769</guid>
      <dc:creator>George K.23</dc:creator>
      <dc:date>2016-02-02T05:13:35Z</dc:date>
    </item>
    <item>
      <title>Re: API session expiry?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/API-session-expiry/m-p/129843#M3770</link>
      <description>&lt;P&gt;No, just retrying (maybe with an exponential backoff) without recreating that object should be fine.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Feb 2016 05:14:46 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/API-session-expiry/m-p/129843#M3770</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2016-02-02T05:14:46Z</dc:date>
    </item>
  </channel>
</rss>

