salesforce-cdp-connector


Namesalesforce-cdp-connector JSON
Version 1.0.13 PyPI version JSON
download
home_pagehttps://github.com/forcedotcom/salesforce-cdp-connector
SummaryPython Connector for Salesforce CDP
upload_time2023-09-08 07:48:50
maintainer
docs_urlNone
authorQuery Service
requires_python>=3.8
licenseBSD-3-Clause
keywords cdp salesforce dbapi
VCS
bugtrack_url
requirements certifi charset-normalizer idna numpy pandas pip pyarrow python-dateutil pytz requests responses setuptools six urllib3 wheel
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # salesforce-cdp-connector

A readonly CDP client for Python. This can be used to execute queries against CDP and load the data into python.

## Usage

### Installation

Install the package from Pypi using the command

```
pip install salesforce-cdp-connector
```

### Quick Start

We have to create an instance of the SalesforceCDPConnection to connect to CDP.

The object can be created as follows:

**Using Username and Password**
```
from salesforcecdpconnector.connection import SalesforceCDPConnection
conn = SalesforceCDPConnection(
        'login_url', 
        'user_name', 
        'password', 
        'client_id', 
        'client_secret'
    )
```

**Using OAuth Tokens**
```
from salesforcecdpconnector.connection import SalesforceCDPConnection
conn = SalesforceCDPConnection(login_url, 
       client_id='<client_id>', 
       client_secret='<client_secret>', 
       core_token='<core token>'
       refresh_token='<refresh_token>'
   )
```

Once the connection object is created the queries can be executed using cursor as follows

```
cur = conn.cursor()
cur.execute('<query>')
results = cur.fetchall()
```

The query results can also be directly extracted as a pandas dataframe

```
dataframe = conn.get_pandas_dataframe('<query>')
```

### Creating a connected App

1. Log in to salesforce as an admin. In the top right corner, click on the gear icon and go to step
2. In the left hand side, under Platform Tools, go to Apps > App Manager
3. Click on New Connected App
4. Fill in the required Basic Information fields.
5. Under API (Enable OAuth Settings)
    1. Click on the checkbox to Enable OAuth Settings.
    2. Provide a callback URL.
    3. In the Selected OAuth Scopes, make sure that refresh_token, api, cdp_query_api, cdp_profile_api is selected.
    4. Click on Save to save the connected app
6. From the page that opens up, click on the Manage Consumer Details to find your client id and client secret

### Fetching Refresh Token

1. From the connected app, note down the below details:
   * Client Id
   * Client Secret
   * Callback URL
2. Obtain the code
   1. From browser, go to the below url.
   ```
   <LOGIN_URL>/services/oauth2/authorize?response_type=code&client_id=<client_id>&redirect_uri=<callback_url>
   ```
   2. This will redirect you to the callback url. The redirected url will be of the form
   ```<callback url>?code=<CODE>```
   3. Extract the CODE from the address bar to be used in next step. Check the network tab of browser if the addressbar doesn't show this.
   
3. Get core and refresh tokens
   1. Make a post call using curl or postman to the below url using the code retrieved in previous step.
   ```
   <LOGIN_URL>/services/oauth2/token?code=<CODE>&grant_type=authorization_code&client_id=<clientId>&client_secret=<clientSecret>&redirect_uri=<callback_uri>
   ```
   2. The response to the above post call will be a json with access_token and refresh_token



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/forcedotcom/salesforce-cdp-connector",
    "name": "salesforce-cdp-connector",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "cdp,salesforce,dbapi",
    "author": "Query Service",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/a2/e6/3f11c504980690b6514b629aebf1a0cf74b461c196074ee695cea4e83fd7/salesforce-cdp-connector-1.0.13.tar.gz",
    "platform": null,
    "description": "# salesforce-cdp-connector\n\nA readonly CDP client for Python. This can be used to execute queries against CDP and load the data into python.\n\n## Usage\n\n### Installation\n\nInstall the package from Pypi using the command\n\n```\npip install salesforce-cdp-connector\n```\n\n### Quick Start\n\nWe have to create an instance of the SalesforceCDPConnection to connect to CDP.\n\nThe object can be created as follows:\n\n**Using Username and Password**\n```\nfrom salesforcecdpconnector.connection import SalesforceCDPConnection\nconn = SalesforceCDPConnection(\n        'login_url', \n        'user_name', \n        'password', \n        'client_id', \n        'client_secret'\n    )\n```\n\n**Using OAuth Tokens**\n```\nfrom salesforcecdpconnector.connection import SalesforceCDPConnection\nconn = SalesforceCDPConnection(login_url, \n       client_id='<client_id>', \n       client_secret='<client_secret>', \n       core_token='<core token>'\n       refresh_token='<refresh_token>'\n   )\n```\n\nOnce the connection object is created the queries can be executed using cursor as follows\n\n```\ncur = conn.cursor()\ncur.execute('<query>')\nresults = cur.fetchall()\n```\n\nThe query results can also be directly extracted as a pandas dataframe\n\n```\ndataframe = conn.get_pandas_dataframe('<query>')\n```\n\n### Creating a connected App\n\n1. Log in to salesforce as an admin. In the top right corner, click on the gear icon and go to step\n2. In the left hand side, under Platform Tools, go to Apps > App Manager\n3. Click on New Connected App\n4. Fill in the required Basic Information fields.\n5. Under API (Enable OAuth Settings)\n    1. Click on the checkbox to Enable OAuth Settings.\n    2. Provide a callback URL.\n    3. In the Selected OAuth Scopes, make sure that refresh_token, api, cdp_query_api, cdp_profile_api is selected.\n    4. Click on Save to save the connected app\n6. From the page that opens up, click on the Manage Consumer Details to find your client id and client secret\n\n### Fetching Refresh Token\n\n1. From the connected app, note down the below details:\n   * Client Id\n   * Client Secret\n   * Callback URL\n2. Obtain the code\n   1. From browser, go to the below url.\n   ```\n   <LOGIN_URL>/services/oauth2/authorize?response_type=code&client_id=<client_id>&redirect_uri=<callback_url>\n   ```\n   2. This will redirect you to the callback url. The redirected url will be of the form\n   ```<callback url>?code=<CODE>```\n   3. Extract the CODE from the address bar to be used in next step. Check the network tab of browser if the addressbar doesn't show this.\n   \n3. Get core and refresh tokens\n   1. Make a post call using curl or postman to the below url using the code retrieved in previous step.\n   ```\n   <LOGIN_URL>/services/oauth2/token?code=<CODE>&grant_type=authorization_code&client_id=<clientId>&client_secret=<clientSecret>&redirect_uri=<callback_uri>\n   ```\n   2. The response to the above post call will be a json with access_token and refresh_token\n\n\n",
    "bugtrack_url": null,
    "license": "BSD-3-Clause",
    "summary": "Python Connector for Salesforce CDP",
    "version": "1.0.13",
    "project_urls": {
        "Homepage": "https://github.com/forcedotcom/salesforce-cdp-connector"
    },
    "split_keywords": [
        "cdp",
        "salesforce",
        "dbapi"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "365cc1aeeeb9cf0b0669e708c1cb0cb9adf8720d5f70f0a652a5038377021084",
                "md5": "04ba63200a3c24cede150f96bd241943",
                "sha256": "825814d60a9782c7b4d75697a9416f96a8ca189206365db6cafcabbe32393245"
            },
            "downloads": -1,
            "filename": "salesforce_cdp_connector-1.0.13-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "04ba63200a3c24cede150f96bd241943",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 18380,
            "upload_time": "2023-09-08T07:48:48",
            "upload_time_iso_8601": "2023-09-08T07:48:48.689503Z",
            "url": "https://files.pythonhosted.org/packages/36/5c/c1aeeeb9cf0b0669e708c1cb0cb9adf8720d5f70f0a652a5038377021084/salesforce_cdp_connector-1.0.13-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a2e63f11c504980690b6514b629aebf1a0cf74b461c196074ee695cea4e83fd7",
                "md5": "38fbf0e22404bb2cc737ee9b47d9c3a1",
                "sha256": "905afa9618f76686dbcf32f895d5bf357876e8261aabfc7b27058e590d8f06a1"
            },
            "downloads": -1,
            "filename": "salesforce-cdp-connector-1.0.13.tar.gz",
            "has_sig": false,
            "md5_digest": "38fbf0e22404bb2cc737ee9b47d9c3a1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 13310,
            "upload_time": "2023-09-08T07:48:50",
            "upload_time_iso_8601": "2023-09-08T07:48:50.447057Z",
            "url": "https://files.pythonhosted.org/packages/a2/e6/3f11c504980690b6514b629aebf1a0cf74b461c196074ee695cea4e83fd7/salesforce-cdp-connector-1.0.13.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-08 07:48:50",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "forcedotcom",
    "github_project": "salesforce-cdp-connector",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "certifi",
            "specs": [
                [
                    "==",
                    "2021.10.8"
                ]
            ]
        },
        {
            "name": "charset-normalizer",
            "specs": [
                [
                    "==",
                    "2.0.10"
                ]
            ]
        },
        {
            "name": "idna",
            "specs": [
                [
                    "==",
                    "3.3"
                ]
            ]
        },
        {
            "name": "numpy",
            "specs": [
                [
                    "==",
                    "1.23.5"
                ]
            ]
        },
        {
            "name": "pandas",
            "specs": [
                [
                    "==",
                    "1.3.5"
                ]
            ]
        },
        {
            "name": "pip",
            "specs": [
                [
                    "==",
                    "22.0.4"
                ]
            ]
        },
        {
            "name": "pyarrow",
            "specs": [
                [
                    "==",
                    "11.0.0"
                ]
            ]
        },
        {
            "name": "python-dateutil",
            "specs": [
                [
                    "==",
                    "2.8.2"
                ]
            ]
        },
        {
            "name": "pytz",
            "specs": [
                [
                    "==",
                    "2021.3"
                ]
            ]
        },
        {
            "name": "requests",
            "specs": [
                [
                    "==",
                    "2.27.1"
                ]
            ]
        },
        {
            "name": "responses",
            "specs": [
                [
                    "==",
                    "0.16.0"
                ]
            ]
        },
        {
            "name": "setuptools",
            "specs": [
                [
                    "==",
                    "60.9.3"
                ]
            ]
        },
        {
            "name": "six",
            "specs": [
                [
                    "==",
                    "1.16.0"
                ]
            ]
        },
        {
            "name": "urllib3",
            "specs": [
                [
                    "==",
                    "1.26.8"
                ]
            ]
        },
        {
            "name": "wheel",
            "specs": [
                [
                    "==",
                    "0.37.1"
                ]
            ]
        }
    ],
    "lcname": "salesforce-cdp-connector"
}
        
Elapsed time: 0.11041s