0

(I asked this on superuser but got no response ...)

I'm trying to follow the tutorial for the Dropbox API at http://taught-process.blogspot.com/2012/05/asdlasd-asda-sd-asd-asdasd.html

But when I get to the last part

#Print the token for future reference
print access_token

What I get back is

<dropbox.session.OAuthToken object at 0x1102d4210>

How do I get the actual token? It should look something like:

oauth_token_secret=xxxxxxx&oauth_token=yyyyyyy

(I'm on a Mac)

3 Answers 3

1

Look around in the properties and methods of the object, to do so apply "dir" on the object. In your case:

dir(access_token)

I'm pretty sure you're gonna find in this object something that will give you the token you need.

Sign up to request clarification or add additional context in comments.

1 Comment

I support this answer because it is the logical way to get more info on used class. In the list you can find access_token.key and access_token.secret values.
1

You've got the right object, yes. But you're dealing with an instance of a class.

<dropbox.session.OAuthToken object at 0x1102d4210>

This is an instance of the OAuthToken object the Dropbox SDK created for you. This token appears to have two attributes: key and secret. These would be your token key and secret. This is what you're after.

You can access them like this:

print access_token.key
print access_token.secret

Comments

0

Using the same tutorial for the Dropbox API at http://taught-process.blogspot.com/2012/05/asdlasd-asda-sd-asd-asdasd.html

Ended up with the following script that worked for me

# Include the Dropbox SDK libraries
from dropbox import client, rest, session

# Get your app key and secret from the Dropbox developer website
APP_KEY = '3w7xv4d9lrkc7c3'
APP_SECRET = '1v5f80mztbd3m9t'

# ACCESS_TYPE should be 'dropbox' or 'app_folder' as configured for your app
ACCESS_TYPE = 'app_folder'

sess = session.DropboxSession(APP_KEY, APP_SECRET, ACCESS_TYPE)
request_token = sess.obtain_request_token()
url = sess.build_authorize_url(request_token)

# Make the user sign in and authorize this token
print "url:", url
print "Please visit this website and press the 'Allow' button, then hit 'Enter' here."
raw_input()

# This will fail if the user didn't visit the above URL
access_token = sess.obtain_access_token(request_token)

#Print the token for future reference
print access_token.key
print access_token.secret

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.