0

I followed the examples here, and created a working script that successfully authenticates with Oauth2 and pulls data from a web API. However, when this code runs in a celery task as part of a Django app it fails with a invalid_client error. The code snipit follows.

app_client = BackendApplicationClient(client_id=config.CLIENT_ID)

headers = {
    "Host": "api.sitescout.com",
    "Authorization": config.AUTHORIZATION_HEADER,
    "Content-Type": "application/x-www-form-urlencoded",
    "Accept": "application/json"
}

token_params = {"grant_type": "client_credentials"}

client = OAuth2Session(client_id=config.CLIENT_ID, client=app_client) 

Is there something I should be doing differently to set up the connection from withing a running web application?

Community
  • 1
  • 1
katahdin
  • 389
  • 7
  • 16
  • Does the `invalid_client` error come from the authorising party or from code on your machine? If the latter, dive into the source and check what conditions raise it; otherwise you could try logging the outgoing request bodies to a file and diff the working and non-working ones. – Ben Graham Feb 03 '16 at 22:19

1 Answers1

0

It turned out that this was an issue with requests_oauthlib. When I applied the patch given here, the error was resolved. This is also fixed in the current master branch.

katahdin
  • 389
  • 7
  • 16