campaignmonitor / createsend-python

A Python library for the Campaign Monitor API
http://campaignmonitor.github.io/createsend-python
MIT License
57 stars 64 forks source link

Python wrapper not working with API connection #65

Closed BrisbanePom closed 3 years ago

BrisbanePom commented 5 years ago

I am trying to connect to my client / campaign using the Python Wrapper and an API connection.

I apply the following code:

from createsend import *

#Connect via API key
cs = CreateSend({'api_key': '123<api-redacted>'})
clients = cs.clients()
auth = {
  'api_key': '123<api-redacted>'
  }

#clients.
 for cl in clients:
     print(cl.Name)
     cl = Client(cl.ClientID,auth)

    #client = Client(cl.ClientID)
    for cm in cl.campaigns():
        print("  - %s" % cm.Subject)

But get the following error message:

Unauthorized: The CreateSend API responded with the following error - 50: Must supply a valid HTTP Basic Authorization header

What do I need to pass to the client to provide a valid authorization header? The documentation explains how to do this with OAuth, but does not show the required code when using the API: https://github.com/campaignmonitor/createsend-python/blob/master/README.md

Trandel commented 3 years ago

I'm having the same issue, is anyone working on that wrapper code?

tobio commented 3 years ago

@Trandel the API documentation includes details on where to get the API Key from.