0

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))
shelbydz
  • 543
  • 6
  • 23

1 Answers1

1

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)
Community
  • 1
  • 1
MaestroFJP
  • 366
  • 1
  • 8
  • Gah, i'm sure this is the problem. I'll give it a shot when I get back to the code. I really wish this was documented somewhere on Vimeo's API site. – shelbydz Oct 29 '13 at 18:11
  • Okay, with the above code I get "Decoder failed to handle XXXX with data as returned by provider. A different decoder may be needed." I'm passing in the access_token and access_token_secret that Vimeo provided to me when I created the application. I'm **not** calling out to the service to get the oauth_verifier first. I'd like to avoid that if it's possible. It seems those returned tokens expire after a few hours. – shelbydz Oct 30 '13 at 19:52
  • i can't, for the life of me, get xauth to work. But i **think** i got session reuse cobbled together with some of your posted examples. first time through I have to call service.get_auth_session. Pull the access_token and access_token_secret for later use. next time through, call 'session.get_session', passing in the stored tokens. I thought I was doing this previously, but I was storing the oauth verify and asking to re-auth. – shelbydz Oct 31 '13 at 16:36