Skip to main content

Python client library for Domain Connect protocol. See: https://domainconnect.org

Project description

domain-connect

Python client library for Domain Connect protocol. For details of the protocol, please visit: https://domainconnect.org

Library offers Service Provider functionality in both Sync and Async mode.

Specification reference

https://github.com/Domain-Connect/spec/blob/master/Domain%20Connect%20Spec%20Draft.adoc

  • Version: 2.1
  • Revision: 52

Usage

Sync flow

Just get the link. Discovery and template query part is solved automatically.

from domainconnect import *

dc = DomainConnect()

try:
    # change 'connect.domains' to any domain you have access to
    res = dc.get_domain_connect_template_sync_url(domain="foo.connect.domains",
                                                  provider_id="exampleservice.domainconnect.org",
                                                  service_id="template1",
                                                  params={"IP": "132.148.25.185",
                                                          "RANDOMTEXT": "shm:1531371203:Hello world sync"},
                                                  redirect_uri="http://example.com", state="{name=value}")
    print(res)
except DomainConnectException as e:
    print('Exception: {}'.format(e))
    raise

Output:

https://domainconnect.1and1.com/sync/v2/domainTemplates/providers/exampleservice.domainconnect.org/services/template1/apply?domain=connect.domains&host=foo&IP=132.148.25.185&RANDOMTEXT=shm%3A1531371203%3AHello+world+sync&redirect_uri=http%3A%2F%2Fexample.com&state=%7Bname%3Dvalue%7D

Async flow

from domainconnect import *

# this will be normally a secret local store on the server
credentials = {
    "1and1": DomainConnectAsyncCredentials(client_id='exampleservice.domainconnect.org',
                                           client_secret='cd$;CVZRj#B8C@o3o8E4v-*k2H7S%)',
                                           api_url='https://api.domainconnect.1and1.com'),
    "GoDaddy": DomainConnectAsyncCredentials(client_id='exampleservice.domainconnect.org',
                                             client_secret='DomainConnectGeheimnisSecretString',
                                             api_url='https://domainconnect.api.godaddy.com'),
}

dc = DomainConnect()

try:
    # change 'connect.domains' to any domain you have access to
    context = dc.get_domain_connect_template_async_context(
        domain='async.connect.domains',
        provider_id='exampleservice.domainconnect.org',
        service_id=['template1', 'template2'], 
        params={"IP": "132.148.25.185", "RANDOMTEXT": "shm:1531371203:Hello world async"},
        redirect_uri='https://exampleservice.domainconnect.org/async_oauth_response')

    # Route the browser to URL by a link
    print('Please open URL: {}'.format(context.asyncConsentUrl))

    # Normally code will arrive as query param on redirect_url
    code = input("Please enter code: ")
    context.code = code

    # token will be written into context. Context can be saved and re-used for async calls
    dc.get_async_token(context, credentials[context.config.providerName])
    print('Token obtained')

    #apply the template any later with the context
    dc.apply_domain_connect_template_async(
        context, 
        service_id='template1', 
        params={"IP": "132.148.25.185", "RANDOMTEXT": "shm:1531371203:Hello world async"}, 
        force=True)
    print('Template applied')
except DomainConnectException as e:
    print('Exception: {}'.format(e))
    raise

Output:

Please open URL: https://domainconnect.1and1.com/async/v2/domainTemplates/providers/exampleservice.domainconnect.org?client_id=exampleservice.domainconnect.org&scope=template1+template2&domain=connect.domains&host=async&IP=132.148.25.185&RANDOMTEXT=shm%3A1531371203%3AHello+world+async&redirect_uri=https%3A%2F%2Fexampleservice.domainconnect.org%2Fasync_oauth_response
Please enter code: >? 8d9a72b5-d2d9-48e3-b615-34fed04d3398
Token obtained
Template applied

Custom http/https proxy or dns resolver

from domainconnect import *

dc = DomainConnect(
    networkcontext=NetworkContext(
        proxy_host='proxy.host', 
        proxy_port='proxy.port', 
        nameservers='resolver.host')
    )

TODOs

  • serialization and deserialization of context for easy storage
  • support for signatures
  • support for provider_name (for shared templates)
  • async revert

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

domain_connect-0.0.4.win-amd64.zip (28.1 kB view details)

Uploaded Source

Built Distribution

domain_connect-0.0.4-py2.py3-none-any.whl (12.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file domain_connect-0.0.4.win-amd64.zip.

File metadata

  • Download URL: domain_connect-0.0.4.win-amd64.zip
  • Upload date:
  • Size: 28.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.3

File hashes

Hashes for domain_connect-0.0.4.win-amd64.zip
Algorithm Hash digest
SHA256 2ced584df566dd371f8cfb427aa65f3624571360bb94f12fcb31b1f5e4ad93a4
MD5 9b8ea9cba199205b27217fe57bde2407
BLAKE2b-256 d1ca20a09317f1b6932e310f23d7d9840f988f31c063f9571f44185e22e910c6

See more details on using hashes here.

File details

Details for the file domain_connect-0.0.4-py2.py3-none-any.whl.

File metadata

  • Download URL: domain_connect-0.0.4-py2.py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.3

File hashes

Hashes for domain_connect-0.0.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a829a9ce887862f2b95ba18e49ff91e1ef5b23d7ea91918e155e77b2d2c0b364
MD5 d99d064c6381c78e5bad6783538b34ef
BLAKE2b-256 0d8dd39ca0d6c0e9c436273f71e837ee381de9a7b6b3ec1c5bdc83d54a762e4e

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