<?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: Beginner question, Powershell, File download in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Beginner-question-Powershell-File-download/m-p/493292#M24648</link>
    <description>&lt;P&gt;It sounds like you actually retrieved an access token from two places:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;your app's page on &lt;A href="https://www.dropbox.com/developers/apps" target="_self"&gt;the App Console&lt;/A&gt;, using the "Generate" button&lt;/LI&gt;
&lt;LI&gt;&lt;A href="https://dropbox.github.io/dropbox-api-v2-explorer/#files_download_zip" target="_self"&gt;the API v2 Explorer&lt;/A&gt;, using the "Get Token" button&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;You do not need to do both however. If you just need an access token for your own account and app, you can just use the first option. Your&amp;nbsp;app's "Access token expiration" setting only applies to your own app, not the API v2 Explorer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It sounds like you then actually used the access token from the API v2 Explorer though, which would be short-lived, and so expires after four hours. (You can tell if an access token is short-lived by looking at the beginning of the string. If it begins with "sl.", it is short-lived.) If you need a long-lived access token for your own app, you should just use option 1 and copy that access token.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In any case, if/when you get an error response from the API, make sure you print out the response body for error information.&lt;/P&gt;</description>
    <pubDate>Wed, 03 Feb 2021 16:07:46 GMT</pubDate>
    <dc:creator>Greg-DB</dc:creator>
    <dc:date>2021-02-03T16:07:46Z</dc:date>
    <item>
      <title>Beginner question, Powershell, File download</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Beginner-question-Powershell-File-download/m-p/491995#M24604</link>
      <description>&lt;P&gt;Sorry, but I have only just started using API. I have built a Powershell script (with help) where from my folder (DropBox file downloads)&lt;BR /&gt;Now I don't know if I did the token part correctly,&lt;/P&gt;
&lt;P&gt;I am on App console created an App, (App folder) and then on&lt;BR /&gt;Generate Access token, (Access token expiration (no expiration)&lt;/P&gt;
&lt;P&gt;1. i have taken the token, this works one time and one time not&lt;/P&gt;
&lt;P&gt;2. then I went to &lt;A href="https://dropbox.github.io/dropbox-api-v2-explorer/#files_download_zip" target="_blank" rel="noopener"&gt;https://dropbox.github.io/dropbox-api-v2-explorer/#files_download_zip&lt;/A&gt; and entered the API token and created Get Token&lt;/P&gt;
&lt;P&gt;This worked a few times (connection from Powershell) and then one time not anymore.&lt;/P&gt;
&lt;P&gt;I would like help because I'm not sure if I'm doing everything right here and if maybe the Powershell script is not so right.&lt;/P&gt;
&lt;P&gt;I would also show my appreciation for the help in some way&lt;/P&gt;
&lt;P&gt;Possibly you can also look at this directly with me TV, Anydesk, Skype etc&lt;BR /&gt;or someone can tell me where I can get help&lt;/P&gt;
&lt;P&gt;Thanks for this and stay healthy&lt;BR /&gt;Rog&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Feb 2021 07:49:40 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Beginner-question-Powershell-File-download/m-p/491995#M24604</guid>
      <dc:creator>MrRog</dc:creator>
      <dc:date>2021-02-02T07:49:40Z</dc:date>
    </item>
    <item>
      <title>Re: Beginner question, Powershell, File download</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Beginner-question-Powershell-File-download/m-p/492536#M24613</link>
      <description>&lt;P&gt;I can't provide API support by remote desktop, phone, or chat, but I'll be happy to help here. I could use some more information about the issue you're seeing though. Can you share the following?&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;the steps to reproduce the issue, including relevant code snippet(s), but don't include any access token(s)&lt;/LI&gt;
&lt;LI&gt;the full text of any error or unexpected output&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Mon, 01 Feb 2021 16:52:54 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Beginner-question-Powershell-File-download/m-p/492536#M24613</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2021-02-01T16:52:54Z</dc:date>
    </item>
    <item>
      <title>Re: Beginner question, Powershell, File download</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Beginner-question-Powershell-File-download/m-p/493075#M24641</link>
      <description>&lt;P&gt;Hello Greg-DB&lt;/P&gt;&lt;P&gt;sure, this is all for testing, when I creating the API I use , App Folder API but someone say thats worng this key is only for 4 hour not more, but Full Dropbox I dont like full acces I need only share 1 Folder&lt;/P&gt;&lt;P&gt;1. Creating a APP then click Generate Access Token, I copy this token and open rul,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://dropbox.github.io/dropbox-api-v2-explorer/#files_download_zip" target="_blank"&gt;https://dropbox.github.io/dropbox-api-v2-explorer/#files_download_zip&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Insert the Token that I have Copy and click Get Token, then this Token I insert to the PS Script&amp;nbsp;$AuthToken&lt;/P&gt;&lt;P&gt;This is working but as y say after 4 hour the Token dosent work anymore&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps, and thx for helping me&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;code&lt;/P&gt;&lt;P&gt;function ParseErrorForResponseBody($Error) {&lt;BR /&gt;if ($PSVersionTable.PSVersion.Major -lt 6) {&lt;BR /&gt;if ($Error.Exception.Response) {&lt;BR /&gt;$Reader = New-Object System.IO.StreamReader($Error.Exception.Response.GetResponseStream())&lt;BR /&gt;$Reader.BaseStream.Position = 0&lt;BR /&gt;$Reader.DiscardBufferedData()&lt;BR /&gt;$ResponseBody = $Reader.ReadToEnd()&lt;BR /&gt;if ($ResponseBody.StartsWith('{')) {&lt;BR /&gt;$ResponseBody = $ResponseBody | ConvertFrom-Json&lt;BR /&gt;}&lt;BR /&gt;return $ResponseBody&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;else {&lt;BR /&gt;return $Error.ErrorDetails.Message&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;function Get-DropboxFolder {&lt;/P&gt;&lt;P&gt;[CmdletBinding()]&lt;BR /&gt;Param(&lt;BR /&gt;[string]$DropboxFolder,&lt;BR /&gt;[string]$OutputFolder,&lt;BR /&gt;[string]$FolderPath&lt;BR /&gt;)&lt;BR /&gt;$body = '{"path":"/'+$DropboxFolder+'"}'&lt;/P&gt;&lt;P&gt;$AuthToken = 'xxxxxxxxxxxxx'&lt;BR /&gt;$token = "Bearer $AuthToken"&lt;BR /&gt;&lt;BR /&gt;#The file will be downloaded as ZIP to the Temp folder of the user&lt;BR /&gt;#$Tempfolder = "$env:temp\Downloaded_File.zip"&lt;BR /&gt;$Tempfolder = "$env:HOMEDRIVE\temp\Downloaded_File.zip"&lt;/P&gt;&lt;P&gt;if (!(Test-Path $FolderPath)){&lt;BR /&gt;Write-Verbose "Downloading the folder..."&lt;BR /&gt;try{&lt;BR /&gt;Invoke-RestMethod `&lt;BR /&gt;-Method POST `&lt;BR /&gt;-Uri "&lt;A href="https://content.dropboxapi.com/2/files/download_zip" target="_blank"&gt;https://content.dropboxapi.com/2/files/download_zip&lt;/A&gt;" `&lt;BR /&gt;-Headers @{ "Authorization" = $token; "Dropbox-API-Arg" = $body} `&lt;BR /&gt;-OutFile $Tempfolder -ContentType ""&lt;BR /&gt;&lt;BR /&gt;#The file will be extracted and then removed from the temp&lt;BR /&gt;write-verbose "Extracting the folder..."&lt;BR /&gt;Expand-Archive -LiteralPath $Tempfolder -DestinationPath $OutputFolder -Force&lt;BR /&gt;write-verbose $OutputFolder&lt;BR /&gt;write-verbose $Tempfolder&lt;BR /&gt;Remove-Item $Tempfolder -Force&lt;BR /&gt;Write-Verbose "The folder has been downloaded."&lt;BR /&gt;}&lt;BR /&gt;catch {&lt;BR /&gt;ParseErrorForResponseBody($_)&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;}else{&lt;BR /&gt;Write-Verbose "Folder Exists."&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;$DropboxFolder = "vpin"&lt;BR /&gt;$OutputFolder = "$env:HOMEDRIVE\temp\1-Downloads"&lt;BR /&gt;$FolderPath = "$OutputFolder\vpin"&lt;/P&gt;&lt;P&gt;Get-DropboxFolder -DropboxFolder $DropboxFolder -OutputFolder $OutputFolder -FolderPath $FolderPath -verbose&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2021 04:37:11 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Beginner-question-Powershell-File-download/m-p/493075#M24641</guid>
      <dc:creator>MrRog</dc:creator>
      <dc:date>2021-02-03T04:37:11Z</dc:date>
    </item>
    <item>
      <title>Re: Beginner question, Powershell, File download</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Beginner-question-Powershell-File-download/m-p/493292#M24648</link>
      <description>&lt;P&gt;It sounds like you actually retrieved an access token from two places:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;your app's page on &lt;A href="https://www.dropbox.com/developers/apps" target="_self"&gt;the App Console&lt;/A&gt;, using the "Generate" button&lt;/LI&gt;
&lt;LI&gt;&lt;A href="https://dropbox.github.io/dropbox-api-v2-explorer/#files_download_zip" target="_self"&gt;the API v2 Explorer&lt;/A&gt;, using the "Get Token" button&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;You do not need to do both however. If you just need an access token for your own account and app, you can just use the first option. Your&amp;nbsp;app's "Access token expiration" setting only applies to your own app, not the API v2 Explorer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It sounds like you then actually used the access token from the API v2 Explorer though, which would be short-lived, and so expires after four hours. (You can tell if an access token is short-lived by looking at the beginning of the string. If it begins with "sl.", it is short-lived.) If you need a long-lived access token for your own app, you should just use option 1 and copy that access token.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In any case, if/when you get an error response from the API, make sure you print out the response body for error information.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2021 16:07:46 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Beginner-question-Powershell-File-download/m-p/493292#M24648</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2021-02-03T16:07:46Z</dc:date>
    </item>
  </channel>
</rss>

