Skip to main content

Messaging SDK for PassBy[ME] Mobile ID solution

Project description

PassBy[ME] Mobile ID client

This library provides you with functionality to handle PassBy[ME] messages.

For further information on PassBy[ME] please visit: www.passbyme.com and sign up for a free account. You can download our API documentation after login.

Table of contents

Installation

Minimum required Python version is 2.7.9.

pip install passbyme2fa_client

Usage

To use the PassBy[ME] Mobile ID SDK first you have to acquire the following:

  • Account authentication PEM file and its password

You can get these after registering at www.passbyme.com, by hitting the “Sign up for free” button. To complete the registration you will need an Android, iOS or Windows Phone device with the PassBy[ME] application installed.

If you login after registration you can download the PEM from the Application menu. You can add new applications to your registration by hitting the “New application”. The application (along with its Application Id) will appear in the table below.

We suggest you to read the available User Guides and API documentation before you continue with the integration. You can download these from the Documentation section of the administration website after login.

PassByME2FAClient

from passbyme2fa_client import *

pbm = PassByME2FAClient(
  key = "auth.pem",
  cert = "auth.pem",
  password = "<auth.pem password>"
)

The PassByME2FAClient constructor accepts the following parameters:

  • key: the path of the authentication key PEM file.

  • cert: the path of the authentication certificate PEM file. (May be the same as key if the PEM file contains both the certificate and the key.)

  • address: The address of the PassBy[ME] service to use. This parameter is optional. by default the SDK will connect to auth-sp.passbyme.com.

Throws a ValueError when a required parameter is missing.

Handling Messages

Sending messages

session_info = pbm.send_message(
  recipients = ["test@pers.on"],
  availability = 300,
  type = PassByME2FAClient.MessageType.AUTHORIZATION,
  subject = "Test subject", body = "Test message"
)

The send_message method accepts the following parameters:

  • recipients: An array containing the PassBy[ME] ID-s of the recipients

  • subject: The subject of the message

  • body: The body of the message

  • availability: The availability of the message in seconds

  • type: One of the following types:

    • PassByME2FAClient.MessageType.AUTHORIZATION - for authorization requests

    • PassByME2FAClient.MessageType.MESSAGE - to send a general message with arbitrary body

    • PassByME2FAClient.MessageType.ESIGN - if the message body contains an esign url

When successful, returns a SessionInfo object.

Throws a ValueError when a required parameter is missing. Throws an HTTPError if an error in HTTP communication occurs. HTTPError.response contains the HTTP response. Throws a PassByMEError if a PassBy[ME] specific error occurs. PassByMEError.response contains the JSON response received from the PassBy[ME] server as a dictionary.

Tracking messages

session_info.refresh()

To track messages, the most efficient way is to call SessionInfo.refresh(). After a successful call, the SessionInfo object will contain up-to-date information about the message.

Throws an HTTPError if an error in HTTP communication occurs. Throws a PassByMEError if a PassBy[ME] specific error occurs.

Cancelling messages

session_info.cancel()

To cancel the message, the most efficient way is to call SessionInfo.cancel(). After a successful call, the message will be cancelled and the SessionInfo object will contain up-to-date information about the message.

Throws an HTTPError if an error in HTTP communication occurs. Throws a PassByMEError if a PassBy[ME] specific error occurs.

SessionInfo

The SessionInfo object describes the state of a message session. It consists of the following attributes:

  • message_id: The id of the message that can be used to reference the message

  • expiration_date: The date and time (as an Arrow object) until which the message can be downloaded with the PassBy[ME] applications

  • recipient_statuses: An array of RecipientStatus objects. Each object consist of the following fields:

    • user_id: The PassBy[ME] ID of the user represented by this recipient object

    • status: The delivery status of this message for this user

Available statuses are (all constants available as PassByME2FAClient.MessageStatus.*):

  • PENDING: Initial status of the message.

  • NOTIFIED: The recipient has been notified about a new message.

  • DOWNLOADED: The recipient has downloaded the message, but has not uploaded the evidence yet.

  • SEEN: The recipient has seen the message and uploaded the evidence.

  • NOT_SEEN: The recipient has not seen the message.

  • NOT_NOTIFIED: The recipient has not received the notification.

  • NOT_DOWNLOADED: The recipient received the notification about the message but has not downloaded the message

  • NO_DEVICE: The message could not be sent because the recipient had no PassBy[ME] ready device that supports messaging.

  • FAILED: The message could not be sent because of an error.

  • DISABLED: The message could not be sent because the recipient is disabled.

  • CANCELLED: The message was cancelled by the sender.

  • APPROVED: Authentication has finished successfully.

  • DENIED: The user has cancelled the authentication.

Errors

HTTPError

Denotes that the server responded with a HTTP error code. Its readable response attribute contains the HTTPResponse received from the server.

PassByMEError

Denotes a PassBy[ME] specific error. See the API documentation for the possible error codes. Its readable response attribute contains the JSON message received from the server as a dictionary.

Build

To build the package, first we have to run our tests, which can be done typing

python setup.py test

If the tests all pass, we can create the distribution package using the command

python setup.py sdist

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

passbyme2fa_client-1.0.7.tar.gz (20.6 kB view details)

Uploaded Source

File details

Details for the file passbyme2fa_client-1.0.7.tar.gz.

File metadata

File hashes

Hashes for passbyme2fa_client-1.0.7.tar.gz
Algorithm Hash digest
SHA256 e4a6ba6a5ff2067b02a6851edc54422c14843d3705ce8b13b9e9315a37ec18be
MD5 995253c99caf73d28c0299e5a2553ff1
BLAKE2b-256 5e0a4c2a23be29e23112bf964365ecdbc651ab7c58fee73fa7b79b7894579cfa

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page