Forum Discussion

lucasromeiro's avatar
lucasromeiro
Explorer | Level 3
7 years ago

Access and file upload using command line (RAW socket)

Hello everyone.
I am trying to login and upar a file in the dropbox using command line, (RAW socket).
I am having difficulty understanding how to do it, because I always get error from my commands.
I am using the reference:
https://www.dropbox.com/developers/documentation/http/documentation

What do I do:

I connect to the dropbox at the following address:
Server IP: api.dropboxapi.com
PORT: 443

I send the commands that have in the above address, to log or send file, but only returns me error, for example:

Sending:
curl -X POST https://api.dropboxapi.com/2/auth/token/from_oauth1 \
    
--header "Authorization: Basic ZzB4a3BtZnUwMjVwbjhmOmtuYWdoMzl3YTc1cxxxxxxxxt" \ "
    
--header "Content-Type: application / json" \
    
-data "{\" oauth1_token \ ": \" g0xkpmfu025xxxx \ ", \" oauth1_token_secret \ ": \" knagh39wa75xxxx \ "}"

I get:
HTTP / 1.1 400 Bad Request
Server: nginx
Date: Thu, 03 May 2018 15:54:37 GMT
Content-Type: text / html
Content-Length:
Connection: close
ETag: "5a7b9900-643a"
X-Dropbox-Request-Id: bd49b7d1aafce148d39e89d17e580d7f

<! DOCTYPE html>

Any command I send, I always get it! I do not understand what I'm doing wrong ....
Can someone help me?

Is there an example command for me to send to test the connection?

 

 

 

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff
    From the sample you provided, I see that you're trying to call /2/auth/token/from_oauth1. This endpoint is only meant for use if you already have pre-existing OAuth 1 access tokens (e.g., retrieved in the past for API v1), which you would plug in there. If you are only starting development now, you would not have OAuth 1 access tokens and so should not be using this endpoint.

    If you don't have pre-existing OAuth 1 access tokens, you should send the user through the normal OAuth 2 app authorization flow. You can find information on how that works in the OAuth guide here:

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

    The documentation for the OAuth 2 app authorization flow can be found here:

    https://www.dropbox.com/developers/documentation/http/documentation#authorization
      • chirstius's avatar
        chirstius
        Icon for Dropbox Staff rankDropbox Staff

        hello lucasromeiro,

         

        As mentioned in the link you referenced, to begin the OAuth 2 flow you would just make a simple GET request, that should be made via the system browser, to:

        https://www.dropbox.com/oauth2/authorize

         

        And supply the parameters as listed, at a bare minimum your request URL would look like:

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

        response_type can either be 'code' or 'token' and client_id is your app key from the developer console (as listed in the description of the /oauth2/authorize documentation).

         

        In this case, if you use the code flow, the user will be presented with a page asking them to login, if they are not already, and then to authorize your application. If they allow it they will be presented a code they can enter back into your app.

         

        Your app can then use:

         

        https://api.dropboxapi.com/oauth2/token

         

        to convert that code into an actual API token you can use to make calls against the Dropbox API. Pay attention to the authorization requirements of this endpoint (again documentation is covered in the link you referenced). This is a POST request vs. a GET for the previous step so adjust and encode parameters accordingly.

         

        Hope that helps get you past this,

         

        -Chuck

         

         

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,941 PostsLatest Activity: 18 hours ago
351 Following

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 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!