pythonoauthvimeoxauth

connecting to vimeo with xauth in python


I'm trying to write a console script to process some videos and automatically upload them. Using my vimeo developer account, I created an application. Each time I upload, it will be with this user's account. I requested and received permission to upload via this account.

I assume I need to connect to the api via xAuth since I won't be able to get the oauth verifier string from the callback url.

I have this python code trying to log in, but I keep getting 400 Bad Request - Missing required parameter - A required parameter was missing.

import oauth2 as oauth

consumer = oauth.Consumer(client_id, client_secret)
        client = oauth.Client(consumer)
        client.add_credentials('email', 'password')
        client.authorizations
        creds = {'Authorization': 'Basic', 'x_auth_username': 'email', 'xauth_password': 'password'}

    params = {}
    params['x_auth_mode'] = 'client_auth'
    params['x_auth_permission'] = 'write'
    params['x_auth_username'] = 'email'
    params['x_auth_password'] = 'password'

    client.set_signature_method = oauth.SignatureMethod_HMAC_SHA1()
    resp, token = client.request('https://vimeo.com/oauth/access_token',
                                 method='POST', body=urllib.urlencode(params),headers=urllib.urlencode(creds))

Solution

  • I think you need the data argument for your callback -- just guessing based off problems with oauth.

    Looks like this problem (although I don't think you need xauth) was asked on SO:

    OAuth Signature not valid error using Rauth, Python against the Vimeo API

    See this ticket -- look at the source of the pull request:

    https://github.com/litl/rauth/pull/133

    Here is a thread directly dealing with Vimeo that I answered a while back that sounds like your issue:

    https://plus.google.com/u/0/109199982702464952248/posts/KGMFVprjbzJ

    This example uses the RAuth library

    from rauth import OAuth1Service
    
    def Authorize():
    vimeo = OAuth1Service(
        name='Vimeo',
        consumer_key=client_id,
        consumer_secret=client_secret,
        request_token_url='https://vimeo.com/oauth/request_token',
        authorize_url='https://vimeo.com/oauth/authorize',
        access_token_url='https://vimeo.com/oauth/access_token',
        base_url='http://vimeo.com/api/rest/v2',
    )
    try:
        request_token, request_token_secret = vimeo.get_request_token(key_token_secret=access_token_secret,data={})
        print(request_token)
    except Exception, e:
        print(e)