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
CHBA
2 years agoExplorer | Level 3
Does the Acces token expire?
I am using Google Apps script to create a PDF file. This is stored in my Google Drive. Yesterday I added to the script that I need a copy of new PDF files send to dropbox. Below is the script I a...
Здравко
Legendary | Level 20
Hi CHBA,
Yes, access token expires (all of them) . Whatever you have read, it's outdated. You need to refresh the access token using refresh token. Take a look here how this can be done without using SDK.
Hope this helps.
CHBA
2 years agoExplorer | Level 3
Hi Здравко
Thanks for a quick reply.
I may end up with another solution as I dont understand how to fix this with a refresh token.
I followed your instruction in the link.
But already here I am stuck:
"In a terminal window execute following curl command:"
curl https://api.dropbox.com/oauth2/token -d code=<received code> -d grant_type=authorization_code -u <App key>:<App secret>
I replace the 'received code', 'App key', and 'App secret' with my own.
When fired off in Powershell, it throws this error after me:
Invoke-WebRequest : Parameter cannot be processed because the parameter name 'u' is ambiguous. Possible matches include
: -UseBasicParsing -Uri -UseDefaultCredentials -UserAgent.
At line:1 char:128
+ ... AAI0RAl8mTa6112h5d6Exxxxxxx -d grant_type=authorization_code -u yamamxxxx ...
+ ~~
+ CategoryInfo : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException
+ FullyQualifiedErrorId : AmbiguousParameter,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
If executed in Git Bash or CMD (I run Windows 11), it gives me this:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 168 100 90 100 78 372 322 --:--:-- --:--:-- --:--:-- 700{"error": "invalid_grant", "error_description": "code has expired (within the last hour)"}
I have tried generating a new token in the App Console under 'Generated access token' and started from the beginning with your guide again, but it didn't seems to change much. The big idiot is stuck 🙂
Why is it saying 'Code has expired within the last hours'? I just generated a new one? I really dont get it..
Even if I did not get this error, I am actually not sure I understand how this works.
I have an app made from Google Appsheet. It is running on a tablet that stays in a public place for people to fill out the form. Whenever they hit SUBMIT the form starts again ready for the next client to fillout the form.
Each form submission goes into my spreadsheet which then creates a PDF based on the data they submitted, and in the end I autoPrint the PDF.
This is where I tried go with Dropbox because the Synchronization goes super fast. The moment google Apps script has created the PDF and sent a copy to Dropbox, the file shows up in the Dropbox drive on the local pc immediately and prints the PDF file to the local printer.
Please bear with me, if you can help me it is super appreaciated. Otherwise I will see if I can find another solution of how to 'Sync' files fast to the pc from cloud.
All the best
- Здравко2 years agoLegendary | Level 20
CHBA wrote:...
"In a terminal window execute following curl command:"curl https://api.dropbox.com/oauth2/token -d code=<received code> -d grant_type=authorization_code -u <App key>:<App secret>
I replace the 'received code', 'App key', and 'App secret' with my own.
When fired off in Powershell, it throws this error after me:Invoke-WebRequest : Parameter cannot be processed because the parameter name 'u' is ambiguous. Possible matches include
: -UseBasicParsing -Uri -UseDefaultCredentials -UserAgent.
At line:1 char:128
+ ... AAI0RAl8mTa6112h5d6Exxxxxxx -d grant_type=authorization_code -u yamamxxxx ...
+ ~~
+ CategoryInfo : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException
+ FullyQualifiedErrorId : AmbiguousParameter,Microsoft.PowerShell.Commands.InvokeWebRequestCommand...
Hi again CHBA,
In the example I linked above to (and in mot Dropbox examples, that are not part of some SDK), curl is in use. It's powerful tool, multi-platform, and widly available. As seems you're NOT a fen of the tool and since use other tools; alright, but take in mind that different tool usually have different usage syntax (including different options)! Just 'translate' the syntax provided in all examples (including the mine) to the syntax suitable for the tools you're using. If you don't do it, the errors you're receiving would be something normal, of course. Again they are NOT a solution, by self, but just examples; that show in practice the used protocol!
CHBA wrote:...
If executed in Git Bash or CMD (I run Windows 11), it gives me this:% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 168 100 90 100 78 372 322 --:--:-- --:--:-- --:--:-- 700{"error": "invalid_grant", "error_description": "code has expired (within the last hour)"}I have tried generating a new token in the App Console under 'Generated access token' and started from the beginning with your guide again, but it didn't seems to change much. The big idiot is stuck 🙂
Why is it saying 'Code has expired within the last hours'? I just generated a new one? I really dont get it.....
This code is a middle step for producing some token (either access token or refresh token). Its purpose is only to confirm users choice to confirm grant access for your application to their data (including to you as a user), nothing more. This code is short lived (supposed to be used within ~10-15 mins) and is one shoot code (once used its validity is gone). The code is NOT access token and cannot be used as such! Follow step by step the process described without modifying it by-self, before be sure what's going on. The only step, that need to be repeated, whenever needed (and embedded in your script; of course, after translation to javascript - where you're using fetch), is the last one (as clearly described within the text)!!! You can save the refresh token (in some constant) and manage the access token and it's expiration moment as described. Read more careful!
Hope this clarifies matter.
- CHBA2 years agoExplorer | Level 3
Hi Здравко
I am sorry if you think I dont read carefully. I have read your thread, googled and a hell lot more to figure out, but sorry that I dont get it.
I have installed Curl on windows, thats why I wrote I tried in Git bash as well and showed here the message I get there.
Also yes, I do understand that 'This code is a middle step for producing some token' but I never come any further.
Thanks for your time.
I need to go with another solution, this is way too complicated for me. But thanks again.- Здравко2 years agoLegendary | Level 20
CHBA wrote:...
Also yes, I do understand that 'This code is a middle step for producing some token' but I never come any further.
...Hmm...🤔 What's going wrong actually? Your issue description isn't very clear (to me at least). Post exact commands and results that passed together with the error you're receiving (to be clear what's on step by step and reproducible). Mask all access/refresh tokens, of course.
CHBA wrote:...
I need to go with another solution, this is way too complicated for me. But thanks again.You can always use the javascript SDK, since you use javascript. There are examples too.
Good luck.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,911 PostsLatest Activity: 8 hours 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!