cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

API V2 oauth 1.0

API V2 oauth 1.0

blink
Explorer | Level 3

Dear all, is oauth 1.0  still use in the future?  That's means use API V2 and use oauth 1.0 through HTTP, TKS!

  
7 Replies 7

Greg-DB
Dropbox Staff
OAuth 1 is only available for use with API v1. API v2 only supports OAuth 2, not OAuth 1.

OAuth 1 will continue to be available for API v1 for the lifespan of API v1 itself. API v1 is deprecated, and you can find the retirement timeline here:

https://blogs.dropbox.com/developers/2016/06/api-v1-deprecated/

blink
Explorer | Level 3

Thanks for your answer.  and I have another question about API V2 oauth 2.0.

I use c++ code to upload files, but how can I get access token by http request with API V2 , eg:

https://www.dropbox.com/oauth2/authorize
https://api.dropboxapi.com/oauth2/token

c++ code :

#include <stdio.h>
#include <curl/curl.h>

int main (int argc, char *argv[])
{
      CURL *curl;
      CURLcode res;

      /* In windows, this will init the winsock stuff */
      curl_global_init(CURL_GLOBAL_ALL);

      /* get a curl handle */
      curl = curl_easy_init();
      if(curl) {

            printf ("Running curl test.\n");

            struct curl_slist *headers=NULL; /* init to NULL is important */
            headers = curl_slist_append(headers, "Authorization: Bearer <ACCESS_TOKEN>");
            headers = curl_slist_append(headers, "Content-Type: application/octet-stream");
            headers = curl_slist_append(headers, "Dropbox-API-Arg: {\"path\":\"/test_c++_upload_test.txt\"}");
            curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);

            curl_easy_setopt(curl, CURLOPT_URL, "https://content.dropboxapi.com/2/files/upload");
            curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "test data for upload");

            /* Perform the request, res will get the return code */
            res = curl_easy_perform(curl);
            /* Check for errors */
            if(res != CURLE_OK)
                  fprintf(stderr, "curl_easy_perform() failed: %s\n",
                    curl_easy_strerror(res));

            /* always cleanup */
              curl_easy_cleanup(curl);

              printf ("\nFinished curl test.\n");

      }
      curl_global_cleanup();

      printf ("Done!\n");
      return 0;

}

 

Greg-DB
Dropbox Staff

You can find information on how the OAuth app authorization flow works here:

https://www.dropbox.com/developers/reference/oauth-guide

The documentation for the specific endpoints you need to use can be found here:

https://www.dropbox.com/developers/documentation/http/documentation#authorization

You can use either the "token" or "code" flow, depending on what makes sense for your app.

Note that https://www.dropbox.com/oauth2/authorize is a web page, not an API endpoint. Your app should direct users there in their browser, and not make any API calls to it directly.

The https://api.dropboxapi.com/oauth2/token URI is an API endpoint that you would use if you use the OAuth 2 "code" flow.

If you run in to any issues implementing that, please let us know the steps to reproduce the issue, and share the relevant code and output so we can look into it.

blink
Explorer | Level 3

Many thanks your answer!  and I've read the the URL doc, but I have a puzzle when I use browse to get token.

  https://www.dropbox.com/oauth2/authorize?client_id=0lksd9ebhsil1qx?response_type=(when can I get the string?).  the browse show 400 error with message:

          More details for developers

          Invalid client_id: "0lksd9ebhsil1qx?response_type=".
Please tell me the url   (https://www.dropbox.com/oauth2/authorize)  Parameters , thank you!

Greg-DB
Dropbox Staff
When constructing a URL, the location should be separated from the parameters by one '?', and subsequent parameters should be separated by '&'.

The 'response_type' should be either 'code' or 'token', depending on which flow you want to use. You can find more information on these in the documentation here:

https://www.dropbox.com/developers/documentation/http/documentation#authorization

So, for example, your /authorize URL might look like this:

https://www.dropbox.com/oauth2/authorize?client_id=0lksd9ebhsil1qx&response_type=code

blink
Explorer | Level 3

Thank you for your answer!  and I can get authorization code by browser.  then  I use
https://api.dropboxapi.com/oauth2/token  API  to get correct result .  but that's not my needed.

 and I don't understand what's the different  between https://api.dropboxapi.com/oauth2/token  result "access_token" and  App Console (Generated access token) .

 in fact, I want to the user input App key and App secret . then I can use API V2  to get access token ,  and I can upload files.  if let's user input access token, it too long and  inconvenient . so please help me. thanks!

Greg-DB
Dropbox Staff
The tokens retrieved by /oauth2/token and the App Console's "Generate" button are the same kind of access tokens. The only thing to note is that the "Generate" button can only be used to get an access token for the single account that owns the app, whereas the OAuth flow can be used to get an access token for any account.

When you develop an API app, you should not require the user to enter their own app key and secret. You, as the developer, only need to register the API app once. You should then use the app key and secret in your app. The app key and secret identify the app. The app can then send the user through the OAuth flow to get an access token for the user.

I recommend reading the OAuth guide for an overview of how this works:

https://www.dropbox.com/developers/reference/oauth-guide
Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    blink Explorer | Level 3
What do Dropbox user levels mean?