Microsoft Communication Messages Client Library for Python
Project description
Azure Communication Messages Package client library for Python
This package contains a Python SDK for Azure Communication Services for Messages(Advanced Messaging). Read more about Azure Communication Services here
Source code | Package (Pypi) | Product documentation
Disclaimer
Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691
Getting started
Prequisites
- Python 3.8 or later is required to use this package.
- You need an Azure subscription to use this package.
- An existing Communication Messages instance.
Key concepts
Azure Communication Services enables you to send and receive WhatsApp messages using the Azure Communication Services Messages SDK. It can be used to send out messages like appointment reminders, shipping updates, two-factor authentication, and other notification scenarios.
Installating the package
python -m pip install azure-communication-messages
Create with an Azure Active Directory Credential
To use an Azure Active Directory (AAD) token credential, provide an instance of the desired credential type obtained from the azure-identity library.
To authenticate with AAD, you must first pip install azure-identity
After setup, you can choose which type of credential from azure.identity to use. As an example, DefaultAzureCredential can be used to authenticate the client:
Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables:
AZURE_CLIENT_ID
, AZURE_TENANT_ID
, AZURE_CLIENT_SECRET
Use the returned token credential to authenticate the client:
>>> from azure.communication.messages import NotificationMessagesClient
>>> from azure.identity import DefaultAzureCredential
>>> client = NotificationMessagesClient(endpoint='<endpoint>', credential=DefaultAzureCredential())
Examples
>>> from azure.communication.messages import NotificationMessagesClient
>>> from azure.identity import DefaultAzureCredential
>>> from azure.core.exceptions import HttpResponseError
>>> client = NotificationMessagesClient(endpoint='<endpoint>', credential=DefaultAzureCredential())
>>> try:
# write test code here
except HttpResponseError as e:
print('service responds error: {}'.format(e.response.json()))
Troubleshooting
Running into issues? This section should contain details as to what to do there.
Next steps
Contributing
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information, see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file azure_communication_messages-1.1.0.tar.gz
.
File metadata
- Download URL: azure_communication_messages-1.1.0.tar.gz
- Upload date:
- Size: 69.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: RestSharp/106.13.0.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d66ac5b4d18406832023c58224f1a982357297a9da5b0f3abd2a219d92214e40 |
|
MD5 | 5f6d1f61a7efb069366750c2c572f517 |
|
BLAKE2b-256 | c9abdcb6a8762cd0a0393e4a92c53cb3cace21680acb0c99d8ebfeec9993eb18 |
File details
Details for the file azure_communication_messages-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: azure_communication_messages-1.1.0-py3-none-any.whl
- Upload date:
- Size: 75.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: RestSharp/106.13.0.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c035b953abd308f60f737d35b1e723e4c7f1f3f4ed19431853069ca06fca5fbe |
|
MD5 | 76e6323515f5da92df9f233f25c1bdb5 |
|
BLAKE2b-256 | 581674c5a394a1db89607b6e353caf28ccc78d43d41565cb0842ca2463d2a681 |