Skip to main content

Python connector for Microsoft Dynamics 365, supports AD, IFD and Online

Project description

pip install pdynamics

from pdynamics import crm

Connect on-premises organizations via user and password

AD access sample:

crmurl = 'http://servername:port/orgname/' user = 'domain\username' password = 'yourpassword' crmorg = crm.client(crmurl, user, password) crmorg.test_connection()

Connect to Dynamics 365 IFD organizations, access_token is required to send requests, it's necessary to create an application group, it has a client id. For example: client id is: 289c7417-83b7-41c3-8fab-68f111b5ba60, and CRM IFD URL is https://mycrmorg.company.com:443/

Run powershell as Admin on AD FS server

PS C:\windows\system32> Grant-AdfsApplicationPermission cmdlet Grant-AdfsApplicationPermission at command pipeline position 1 Supply values for the following parameters: ClientRoleIdentifier: 289c7417-83b7-41c3-8fab-68f111b5ba60 ServerRoleIdentifier: https://mycrmorg.company.com:443/

What's the token endpoint?

When log in CRM, system will redirect to ADFS login page, url is something like https://mycrmorg.company.com:5555/adfs/ls/?wa=wsignin1.0&wtrealm=....., then your token endpoint will be https://mycrmorg.company.com:5555/adfs/oauth2/token

IFD Connection Sample:

crmurl = 'https://mycrmorg.company.com:443/' tokenurl = 'https://mycrmorg.company.com:5555/adfs/oauth2/token' user = 'domain\username' password = 'yourpassword' clientid = '289c7417-83b7-41c3-8fab-68f111b5ba60' crmorg = crm.client(crmurl, user, password, clientid, tokenurl) crmorg.test_connection()

Access Dynamics 365 Online:

  1. Go to office 365 admin center -> Azure Active Directory or https://aad.portal.azure.com/yourcompanydomain
  2. Azure Active Directory -> App registrations -> Register an application a. input a Name b. select "Accounts in this organizational directory only (Single tenant)" - other options might also work c. Manage -> Certificates & secrets -> New client secret (keep this client_secret for later use) d. API permissions -> Add a permission -> Select an API -> Microsoft APIs-> Dynamics CRM e. Grant admin consent for '{your company}' f. Find client id (Application ID) in Overview page

Dynamics 365 Online Connection Sample:

crmurl = 'https://mycrmorg.crm.dynamics.com/' user = 'username@mycrmorg.onmicrosoft.com' password = 'yourpassword' clientid = '289c7417-83b7-41c3-8fab-68f111b5ba60' clientsecret = 'Pq-oEk~_7044Q2VQGXwaH2v9k0qlSG1K' crmorg = crm.client(crmurl, user, password, clientid, client_secret=clientsecret) crmorg.test_connection()

It's your own risk to use this library.

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

pdynamics-0.2.1.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pdynamics-0.2.1-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file pdynamics-0.2.1.tar.gz.

File metadata

  • Download URL: pdynamics-0.2.1.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for pdynamics-0.2.1.tar.gz
Algorithm Hash digest
SHA256 21d1f67d6620e1e01b93151322754824af95061d739482c6fdb0eca8479ef8b3
MD5 80b7fee22214a4f54b501c532414845e
BLAKE2b-256 a8e15ed5239bc7b861f07e925cab6462705ba4070f3427ba8782cf0885b75de3

See more details on using hashes here.

File details

Details for the file pdynamics-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: pdynamics-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for pdynamics-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 aa9909f298824099fd20d1861d44054182a50659740ce1a35cbc675de80579ef
MD5 b5efc7524a5724d13669530034cbf2f6
BLAKE2b-256 a91b1781b50342016963796e986eb34953bc39a4791e2f62e8f758c6841a1d09

See more details on using hashes here.

Supported by

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