httpie-salesforce 0.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- httpie_salesforce-0.2.2/LICENSE +28 -0
- httpie_salesforce-0.2.2/PKG-INFO +34 -0
- httpie_salesforce-0.2.2/README.md +11 -0
- httpie_salesforce-0.2.2/httpie_salesforce.egg-info/PKG-INFO +34 -0
- httpie_salesforce-0.2.2/httpie_salesforce.egg-info/SOURCES.txt +11 -0
- httpie_salesforce-0.2.2/httpie_salesforce.egg-info/dependency_links.txt +1 -0
- httpie_salesforce-0.2.2/httpie_salesforce.egg-info/requires.txt +2 -0
- httpie_salesforce-0.2.2/httpie_salesforce.egg-info/top_level.txt +1 -0
- httpie_salesforce-0.2.2/httpie_salesforce.py +76 -0
- httpie_salesforce-0.2.2/pyproject.toml +39 -0
- httpie_salesforce-0.2.2/setup.cfg +4 -0
- httpie_salesforce-0.2.2/tests/test_password_flow.py +22 -0
- httpie_salesforce-0.2.2/tests/test_plugin_init.py +22 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026, Dmytro Larkin
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: httpie-salesforce
|
|
3
|
+
Version: 0.2.2
|
|
4
|
+
Summary: HTTPie Authorization plugin for Salesforce API
|
|
5
|
+
Author-email: Dmytro Larkin <dmitry.larkin@gmail.com>
|
|
6
|
+
License-Expression: BSD-3-Clause
|
|
7
|
+
Project-URL: Homepage, https://github.com/dml/httpie-salesforce
|
|
8
|
+
Project-URL: Repository, https://github.com/dml/httpie-salesforce.git
|
|
9
|
+
Project-URL: Issues, https://github.com/dml/httpie-salesforce/issues
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: httpie>=3.2.4
|
|
21
|
+
Requires-Dist: requests>=2.32.5
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
|
|
24
|
+
# HTTPie Salesforce Plugin
|
|
25
|
+
|
|
26
|
+
Salesforce REST API authorization with HTTPie.
|
|
27
|
+
|
|
28
|
+
## Install Plugin
|
|
29
|
+
|
|
30
|
+
...
|
|
31
|
+
|
|
32
|
+
## Use OAuth Flows
|
|
33
|
+
|
|
34
|
+
https://help.salesforce.com/s/articleView?id=xcloud.remoteaccess_authenticate.htm
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: httpie-salesforce
|
|
3
|
+
Version: 0.2.2
|
|
4
|
+
Summary: HTTPie Authorization plugin for Salesforce API
|
|
5
|
+
Author-email: Dmytro Larkin <dmitry.larkin@gmail.com>
|
|
6
|
+
License-Expression: BSD-3-Clause
|
|
7
|
+
Project-URL: Homepage, https://github.com/dml/httpie-salesforce
|
|
8
|
+
Project-URL: Repository, https://github.com/dml/httpie-salesforce.git
|
|
9
|
+
Project-URL: Issues, https://github.com/dml/httpie-salesforce/issues
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: httpie>=3.2.4
|
|
21
|
+
Requires-Dist: requests>=2.32.5
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
|
|
24
|
+
# HTTPie Salesforce Plugin
|
|
25
|
+
|
|
26
|
+
Salesforce REST API authorization with HTTPie.
|
|
27
|
+
|
|
28
|
+
## Install Plugin
|
|
29
|
+
|
|
30
|
+
...
|
|
31
|
+
|
|
32
|
+
## Use OAuth Flows
|
|
33
|
+
|
|
34
|
+
https://help.salesforce.com/s/articleView?id=xcloud.remoteaccess_authenticate.htm
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
httpie_salesforce.py
|
|
4
|
+
pyproject.toml
|
|
5
|
+
httpie_salesforce.egg-info/PKG-INFO
|
|
6
|
+
httpie_salesforce.egg-info/SOURCES.txt
|
|
7
|
+
httpie_salesforce.egg-info/dependency_links.txt
|
|
8
|
+
httpie_salesforce.egg-info/requires.txt
|
|
9
|
+
httpie_salesforce.egg-info/top_level.txt
|
|
10
|
+
tests/test_password_flow.py
|
|
11
|
+
tests/test_plugin_init.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
httpie_salesforce
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Salesforce API auth plugin for HTTPie.
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import importlib.metadata
|
|
7
|
+
import os
|
|
8
|
+
import sys
|
|
9
|
+
|
|
10
|
+
import requests
|
|
11
|
+
from httpie.plugins import AuthPlugin
|
|
12
|
+
|
|
13
|
+
__version__ = importlib.metadata.version("httpie-salesforce")
|
|
14
|
+
__author__ = "Dmytro Larkin"
|
|
15
|
+
__licence__ = "BSD"
|
|
16
|
+
|
|
17
|
+
SANDBOX_LOGIN_URL = "https://test.salesforce.com/services/oauth2/token"
|
|
18
|
+
PRODUCTION_LOGIN_URL = "https://login.salesforce.com/services/oauth2/token"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class BaseFlow:
|
|
22
|
+
@property
|
|
23
|
+
def url(self):
|
|
24
|
+
if os.environ.get("SF_TEST") is not None:
|
|
25
|
+
return SANDBOX_LOGIN_URL
|
|
26
|
+
|
|
27
|
+
return PRODUCTION_LOGIN_URL
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class PasswordFlow(BaseFlow):
|
|
31
|
+
def __init__(self):
|
|
32
|
+
self.client_id = os.environ.get("SF_CLIENT_ID")
|
|
33
|
+
self.client_secret = os.environ.get("SF_CLIENT_SECRET")
|
|
34
|
+
self.username = os.environ.get("SF_USERNAME")
|
|
35
|
+
self.password = os.environ.get("SF_PASSWORD")
|
|
36
|
+
self.token = os.environ.get("SF_TOKEN")
|
|
37
|
+
|
|
38
|
+
def __call__(self, request):
|
|
39
|
+
response = requests.post(self.url, data=self.payload).json()
|
|
40
|
+
access_token = response.get("access_token")
|
|
41
|
+
request.headers.update({"Authorization": "Bearer %s" % access_token})
|
|
42
|
+
|
|
43
|
+
return request
|
|
44
|
+
|
|
45
|
+
@property
|
|
46
|
+
def payload(self):
|
|
47
|
+
return {
|
|
48
|
+
"grant_type": "password",
|
|
49
|
+
"client_id": self.client_id,
|
|
50
|
+
"client_secret": self.client_secret,
|
|
51
|
+
"username": self.username,
|
|
52
|
+
"password": f"{self.password}{self.token}",
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class SalesforceAuthPlugin(AuthPlugin):
|
|
57
|
+
"""Plugin registration"""
|
|
58
|
+
|
|
59
|
+
name = "Salesforce REST API Auth"
|
|
60
|
+
auth_type = "salesforce"
|
|
61
|
+
description = "Set a Salesforce REST API request token by executin OAuth 2.0 flow"
|
|
62
|
+
auth_require = False
|
|
63
|
+
prompt_password = False
|
|
64
|
+
|
|
65
|
+
def get_auth(self, username: str | None = None, password: str | None = None):
|
|
66
|
+
return PasswordFlow()
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
if __name__ == "__main__" and len(sys.argv) == 2:
|
|
70
|
+
session = requests.Session()
|
|
71
|
+
auth = PasswordFlow()
|
|
72
|
+
request = auth(session).get(sys.argv[1])
|
|
73
|
+
|
|
74
|
+
print(request.url)
|
|
75
|
+
print(request.headers)
|
|
76
|
+
print(request.json())
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "httpie-salesforce"
|
|
7
|
+
version = "0.2.2"
|
|
8
|
+
description = "HTTPie Authorization plugin for Salesforce API"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "BSD-3-Clause"
|
|
11
|
+
license-files = ["LICENSE"]
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "Dmytro Larkin", email = "dmitry.larkin@gmail.com"},
|
|
14
|
+
]
|
|
15
|
+
requires-python = ">=3.10"
|
|
16
|
+
dependencies = [
|
|
17
|
+
"httpie>=3.2.4",
|
|
18
|
+
"requests>=2.32.5",
|
|
19
|
+
]
|
|
20
|
+
classifiers = [
|
|
21
|
+
"Development Status :: 3 - Alpha",
|
|
22
|
+
"Intended Audience :: Developers",
|
|
23
|
+
"Programming Language :: Python :: 3.10",
|
|
24
|
+
"Programming Language :: Python :: 3.11",
|
|
25
|
+
"Programming Language :: Python :: 3.12",
|
|
26
|
+
"Programming Language :: Python :: 3.13",
|
|
27
|
+
"Programming Language :: Python :: 3.14",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
[project.urls]
|
|
31
|
+
Homepage = "https://github.com/dml/httpie-salesforce"
|
|
32
|
+
Repository = "https://github.com/dml/httpie-salesforce.git"
|
|
33
|
+
Issues = "https://github.com/dml/httpie-salesforce/issues"
|
|
34
|
+
|
|
35
|
+
[[tool.uv.index]]
|
|
36
|
+
name = "test"
|
|
37
|
+
url = "https://test.pypi.org/simple/"
|
|
38
|
+
publish-url = "https://test.pypi.org/legacy/"
|
|
39
|
+
explicit = true
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
3
|
+
import httpie_salesforce
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@pytest.fixture
|
|
7
|
+
def flow():
|
|
8
|
+
return httpie_salesforce.PasswordFlow()
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def test_url(flow):
|
|
12
|
+
assert flow.url == "https://login.salesforce.com/services/oauth2/token"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def test_payload(flow):
|
|
16
|
+
assert flow.payload == {
|
|
17
|
+
"grant_type": "password",
|
|
18
|
+
"client_id": "test-client-id",
|
|
19
|
+
"client_secret": "test-client-secret",
|
|
20
|
+
"username": "test-username",
|
|
21
|
+
"password": "test-passwordtest-security-token",
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
3
|
+
import httpie_salesforce
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@pytest.fixture
|
|
7
|
+
def plugin():
|
|
8
|
+
return httpie_salesforce.SalesforceAuthPlugin()
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def test_init(plugin):
|
|
12
|
+
assert plugin.name == "Salesforce REST API Auth"
|
|
13
|
+
assert plugin.auth_type == "salesforce"
|
|
14
|
+
assert plugin.description == (
|
|
15
|
+
"Set a Salesforce REST API request token by executin OAuth 2.0 flow"
|
|
16
|
+
)
|
|
17
|
+
assert plugin.auth_require is False
|
|
18
|
+
assert plugin.prompt_password is False
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def test_get_auth(plugin):
|
|
22
|
+
assert isinstance(plugin.get_auth(), httpie_salesforce.PasswordFlow)
|