Printful API Key on Python script

Viewed 323

I will use the Printfull API, but I can't find on way to test the API Key, on my script. Some of you can tell me how is the best way to do this? Thank you. Flavio

import json
import requests

key = ('random:key')
r = requests.get('https://api.printful.com/sync/products')
packages_json = r.key.json()

print(packages_json)
1 Answers

Authorization to Printful API would look something like this:

import base64

key = 'random:key'
key = base64.b64encode(bytes(key, 'utf-8'))
keyDecoded = key.decode('ascii')
header = {'Authorization': 'Basic ' + keyDecoded}
requests.get(url, headers=header)

Let me know if this worked for you

Related