Basic authentication with Wordpress RESTAPI using python Wordpress pip package


Staff member
I am trying to create a basic authentication with WordPress RestAPI. I am trying to connect to a WordPress website hosted on localhost virtual Bitnami Environment.
I have installed an application password plugin to obtain an app password and trying to connect now with the <a href="" rel="nofollow noreferrer">following python package</a> but for some reason when I print the response, I am getting 401.
Still, the JSON file is accessible from the web browser and shows the content.
print(&quot;Current Time =&quot;, current_date())

config = configparser.ConfigParser()'settings.ini')
url = config['WordpressRestAPI']['url']
user = config['WordpressRestAPI']['wpUser']
password = config['WordpressRestAPI']['wpPass']

credentials = user + ':' + password
token = base64.b64encode(credentials.encode())

header = {'Authorization': 'Basic' + token.decode('utf-8')}
post = {
    'title': 'Danny',
    'content': 'Hello World',
    'status': 'publish'

additional_metas = {'date_gmt': current_date(),
                    'slug': 'Danny',
                    'author': 2,
                    'featured_media': 41,
                    'type': 'influencer',
                    'comment_status': 'closed',
                    'ping_status': 'open',
                    'format': 'standard'}
post_type_name = config['WordpressRestAPI']['postTypeName']
r = + post_type_name, headers=header, json=post)
This is the configuration I made:
    url =
    wpUser = abc
    wpPass = aaaa bbbb cccc dddd eeee ffff
    postTypeName = influencers