Forum Discussion

aalok's avatar
aalok
Explorer | Level 4
4 years ago

generate code by using curl dropbox api

I don't want user interaction to click and allow a button to get code. I want to get it through curl or api.

4 Replies

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    4 years ago

    It is not possible to fully automate the OAuth process where the user chooses to authorize the app and the app then receives the resulting access token and optional refresh token. This needs to be done manually by the user at least once. If your app needs to maintain long-term access without the user manually re-authorizing it repeatedly, the app should request "offline" access so that it gets a refresh token. The refresh token doesn't expire and can be stored and used repeatedly to get new short-lived access tokens whenever needed, without the user manually reauthorizing the app.

     

    You can find more information on this in the OAuth Guide and authorization documentation.

  • aalok's avatar
    aalok
    Explorer | Level 4
    4 years ago

    Any curl API to get refresh token and how to check whether access token expired or not.plz, send me an updated API document link.

  • Здравко's avatar
    Здравко
    Legendary | Level 20
    4 years ago

    Hi aalok,

    A minimalistic example of what you're asking for can be seen here. The example shows API access using CURL, but it's the same while using any other way/HTTP access method (HTTP client). Of course, once get familiar with the OAuth' idea, you can extend the example to use different authentication methods (PKCE, for instance) and improve automation (with a loopback port to get the code without copy/paste, using 'netcat' for example or similar). 😉

    Hope this helps.

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    4 years ago

    aalok Yes, the links in my previous message as well as the link that Здравко shared show how to use the OAuth app authorization flow.

     

    Attempting to use an expired short-lived access token will fail with the "expired_access_token" error. Refer to the Error documentation and Error Handling Guide for more information on handling errors.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If 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, Facebook or Instagram.

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!