Authentication Credentials

The credentials classes are used to encapsulate all authentication information for the ConnectionParameters class.

The PlainCredentials class returns the properly formatted username and password to the Connection.

To authenticate with Pika, create a PlainCredentials object passing in the username and password and pass it as the credentials argument value to the ConnectionParameters object.

If you are using URLParameters you do not need a credentials object, one will automatically be created for you.

If you are looking to implement SSL certificate style authentication, you would extend the ExternalCredentials class implementing the required behavior.

PlainCredentials

class pika.credentials.PlainCredentials(username, password, erase_on_connect=False)

A credentials object for the default authentication methodology with RabbitMQ.

If you do not pass in credentials to the ConnectionParameters object, it will create credentials for ‘guest’ with the password of ‘guest’.

If you pass True to erase_on_connect the credentials will not be stored in memory after the Connection attempt has been made.

Parameters:
  • username (str) – The username to authenticate with
  • password (str) – The password to authenticate with
  • erase_on_connect (bool) – erase credentials on connect.
erase_credentials()

Called by Connection when it no longer needs the credentials

response_for(start)

Validate that this type of authentication is supported

Parameters:start (spec.Connection.Start) – Connection.Start method
Return type:tuple(str|None, str|None)

ExternalCredentials

class pika.credentials.ExternalCredentials

The ExternalCredentials class allows the connection to use EXTERNAL authentication, generally with a client SSL certificate.

erase_credentials()

Called by Connection when it no longer needs the credentials

response_for(start)

Validate that this type of authentication is supported

Parameters:start (spec.Connection.Start) – Connection.Start method
Return type:tuple(str or None, str or None)