Search code examples
pythonapioauthrauth

Unable to get tokens from get_raw_request_token() in Rauth


I'm using Rauth for requests to the Beatport API

The following is a part of my code

from rauth import OAuth1Service

beatport = OAuth1Service(
    name='beatport',
    consumer_key='xxxxxxxxxxxxxxxxxxxxxxxx',
    consumer_secret='xxxxxxxxxxxxxxxxxxxxxxx',
    request_token_url='https://oauth-api.beatport.com/identity/1/oauth/request-token',
    access_token_url='https://oauth-api.beatport.com/identity/1/oauth/access-token',
    authorize_url='https://oauth-api.beatport.com/identity/1/oauth/authorize',
    base_url='https://oauth-api.beatport.com/json/catalog')

print beatport.get_raw_request_token()

request_token, request_token_secret = beatport.get_raw_request_token()

The print beatport.get_raw_request_token() prints Response [405]. The consumer key and consumer secret i'm using are correct and valid.

Beatport API Documentation

Rauth Documentation

What am I doing wrong?


Solution

  • The value of calling beatport.get_raw_request_token() is a Requests' response object. With this object, you can see exactly what happened. However, even just by printing it you can see the return code was HTTP 405. This response code indicates "Invalid Method", meaning the request method used was incorrect. You probably need to use a GET or POST (I'm forgetting the default request method here) to satisfy the Beatport API.