Python Forum
how to connect and read fiels from dropbox using Python3.6?
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to connect and read fiels from dropbox using Python3.6?
#1
Hi ALl,

Has anyone connected with the dropbox using Python3.6?

I am trying to first connect with the drobox and then I need to read some csv files from there.
For that I have written a helper class which have functions-connect,read etc.

I have read the api v2 doc api v2 drobox doc

But couldn't find the way to achieve my goal.Below is my code snippet for this but it is not complete and need your help-

class DropBoxHelper(object):
    def connect_to_dropbox(self):
        config = configparser.ConfigParser()
        config.read(os.path.abspath(os.pardir) + '/config.ini')
        app_key = config['DROPBOX']['KEY']
        app_secret = config['DROPBOX']['SECRET']
        access_type = "dropbox"
        session = dropbox.Dropbox(app_key)

if __name__ == '__main__':
    DropBoxHelper.connect_to_dropbox(object)
Can anyone please look into this and share me how to complete this?
Reply
#2
take a look at: https://github.com/dropbox/dropbox-sdk-python/issues/89
Reply
#3
Since docs are not clear to me, I am sharing my solution so that it may help others also-
In dropbox's app console we need to generate access token which can be used as below:
    def connect_to_dropbox(self):
        config = configparser.ConfigParser()
        config.read(os.path.abspath(os.pardir) + '/config.ini')
        access_token = config['DROPBOX']['ACCESS_TOKEN']
        dbx = dropbox.Dropbox(access_token)
        return dbx
In above code I am storing the dropbox credentials in config.ini file and passing it to the Dropbox() method.
With this way I am able to connect with the dropbox successfully.
Reply
#4
(Jul-11-2018, 05:20 AM)PrateekG Wrote: Since docs are not clear
That is pretty much your opinion. Did you read

https://www.dropbox.com/developers/docum...n#tutorial

Quote:Link an account

In order to make calls to the API, you'll need an instance of the Dropbox object. To instantiate, pass in the access token for the account you want to link. (Tip: You can generate an access token for your own account through the App Console).
dbx = dropbox.Dropbox('YOUR_ACCESS_TOKEN')
Test it out to make sure you've linked the right account:
dbx.users_get_current_account()
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#5
(Jul-11-2018, 06:57 AM)buran Wrote:
(Jul-11-2018, 05:20 AM)PrateekG Wrote: Since docs are not clear
That is pretty much your opinion. Did you read

https://www.dropbox.com/developers/docum...n#tutorial

Quote:Link an account

In order to make calls to the API, you'll need an instance of the Dropbox object. To instantiate, pass in the access token for the account you want to link. (Tip: You can generate an access token for your own account through the App Console).
dbx = dropbox.Dropbox('YOUR_ACCESS_TOKEN')
Test it out to make sure you've linked the right account:
dbx.users_get_current_account()

Yes Buran, it was my opinion and I hope you will come forward very first next time to help others!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to ignore "Retrying (Retry(total=2, connect=2, read=5, redirect=5, status=None))" const 3 2,691 Mar-26-2022, 08:55 AM
Last Post: ndc85430
  Python3: how to read binary? alexel 0 1,504 Feb-03-2020, 09:18 PM
Last Post: alexel
  Gnuradio python3 is not compatible python3 xmlrpc library How Can I Fix İt ? muratoznnnn 3 4,893 Nov-07-2019, 05:47 PM
Last Post: DeaD_EyE
  Connect to SFTP to read cvs files arunlal 1 3,014 Nov-20-2018, 08:32 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020