Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Librabry does not support dropbox #44

Closed
sferich888 opened this issue Sep 21, 2013 · 9 comments

Comments

@sferich888
Copy link

commented Sep 21, 2013

Using the examples provided and the DropBox exmple

I have created an example based on the Facebook example however I don't think that something (either the flask libraries or dropbox) are following the spec?

  • Problem is I am not sure which / who?
from flask import Flask, render_template, request, redirect, session, url_for, flash
from flask_oauthlib.client import OAuth

app = Flask(__name__)

app.config['PROPAGATE_EXCEPTIONS'] = True
app.secret_key="not so secret"

oauth = OAuth()
dropbox = oauth.remote_app('dropbox',
    base_url='https://api.dropbox.com/1/oauth',
    request_token_url='https://api.dropbox.com/1/oauth/request_token',
    access_token_url='https://api.dropbox.com/1/oauth/access_token',
    authorize_url='https://www.dropbox.com/1/oauth/authorize/',
    consumer_key='KEY',
    consumer_secret='SECRET'
)

@app.route('/login')
def login():
    print dropbox.authorize(callback=url_for('dropbox_authorized',
        next=request.args.get('next') or request.referrer or None,
        _external=True))
    return dropbox.authorize(callback=url_for('dropbox_authorized',
        next=request.args.get('next') or request.referrer or None,
        _external=True))

@app.route('/login/authorized')
@dropbox.authorized_handler
def dropbox_authorized(resp):
    if resp is None:
        return 'Access denied: reason=%s error=%s' % (
            request.args['error_reason'],
            request.args['error_description']
        )
    session['oauth_token'] = (resp['access_token'], '')
    me = dropbox.get('/me')
    return 'Logged in as id=%s name=%s redirect=%s' % \
        (me.data['id'], me.data['name'], request.args.get('next'))

@dropbox.tokengetter
def get_dropbox_oauth_token():
    return session.get('oauth_token')

if __name__ == "__main__":
    app.run()

It would seem that the DropBox exmple is expecting this Line to redirect you back to the application using the &oauth_callback= parameters.

With the following code edit to this Line I was able to get redirected back to my application however I did get a 400 Bad Request with http://localhost:5000/login/authorized?uid=UUID&oauth_token=TOKEN as the URL.

url = '%s?oauth_token=%s&oauth_callback=%s' % (
                self.expand_url(self.authorize_url), url_quote(token),
                "http://localhost:5000/login/authorized"
            )

I assume the 400 error is due to the dropbox_authorized code not properly handling the response. Any thoughts?

@lepture

This comment has been minimized.

Copy link
Owner

commented Sep 21, 2013

https://www.dropbox.com/developers/core/docs

Dropbox supports both oauth1 and oauth2. This is the documentation you need.

If you are using oauth1, take twitter as the example, if you are using oauth2, take facebook as the example.

@sferich888

This comment has been minimized.

Copy link
Author

commented Sep 21, 2013

@lepture thanks for the pointer however after making a few alterations to the code above:

oauth = OAuth()
dropbox = oauth.remote_app('dropbox',
    base_url='https://api.dropbox.com/1/',
    request_token_url=None,
    access_token_url='https://api.dropbox.com/1/oauth2/token',
    authorize_url='https://www.dropbox.com/1/oauth2/authorize',
    consumer_key='KEY',
    consumer_secret='SECRET'
)

After making these changes to use the proper URI's for the DrobBox API's it seems that you still have an error:

  File "/home/USER/Repositories/pytod/lib/python2.7/site-packages/Flask_OAuthlib-0.3.2-py2.7.egg/flask_oauthlib/client.py", line 462, in authorize
    scope = params.pop('scope')
KeyError: 'scope'

I think this is caused because of the returned perimeters by the facebook and drop box api's. If you look at the dropbox docs and compare the parameters to the facebook docs you can see that dropbox does not have a scop parameter which I think is a bug in this API.

What are your thoughts?

@lepture

This comment has been minimized.

Copy link
Owner

commented Sep 21, 2013

@sferich888 Try with the source code of this repo, if it didn't work. I will look into it tomorrow.

lepture added a commit that referenced this issue Sep 22, 2013

lepture added a commit that referenced this issue Sep 22, 2013

@sferich888

This comment has been minimized.

Copy link
Author

commented Sep 22, 2013

@lepture with abf0755a013c2e4dd2fbd106126a4fcc16fc18ed in place your example works, and I can begin using this to work on my app. Thanks!

Any Idea when this will be available with pip? I will not be able to use this until its pushed to pip but at least now I can develop the dropbox integration, and I can just hold of on pushing the code till this is resolved and pushed to pip.

Thanks for the help!

@lepture

This comment has been minimized.

Copy link
Owner

commented Sep 22, 2013

@sferich888 What's your dead line? I hope it will be released in 3 weeks.

@sferich888

This comment has been minimized.

Copy link
Author

commented Sep 22, 2013

@lepture I was hoping to have that released sooner than 3 weeks (I would like to see if this work in OpenShift), but if that is how long it takes I can wait (I am honestly in no rush), can you update me when the release is finalized?

@lepture

This comment has been minimized.

Copy link
Owner

commented Oct 4, 2013

@sferich888 0.3.3 is released.

@lepture lepture closed this Oct 4, 2013

@lepture

This comment has been minimized.

Copy link
Owner

commented Nov 4, 2013

@sferich888 any response?

@sferich888

This comment has been minimized.

Copy link
Author

commented Nov 4, 2013

Due to some family issues i have not had a chance to 'officaly' test this
but the initial tests we did looked good.

However i was looking at this thinking it needed more drop box api access /
control however that may be out of the scope for this library.
On Nov 3, 2013 10:59 PM, "Hsiaoming Yang" notifications@github.com wrote:

@sferich888 https://github.com/sferich888 any response?


Reply to this email directly or view it on GitHubhttps://github.com//issues/44#issuecomment-27663665
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.