Skip to content

Commit ebcc5df

Browse files
authored
Release 20.11 (#10)
Documentation and code samples updated
1 parent 37e1553 commit ebcc5df

8 files changed

Lines changed: 30 additions & 28 deletions

File tree

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Aspose.BarCode Cloud SDK for Python
22

33
- API version: 3.0
4-
- Package version: 20.10.0
4+
- Package version: 20.11.0
55

66
[Aspose.BarCode for Cloud](https://products.aspose.cloud/barcode/cloud) is a REST API for Linear, 2D and postal barcode generation and recognition in the cloud. API recognizes and generates barcode images in a variety of formats. Barcode REST API allows to specify barcode image attributes like image width, height, border style and output image format in order to customize the generation process. Developers can also specify the barcode type and text attributes such as text location and font styles in order to suit the application requirements.
77

@@ -12,15 +12,15 @@ Supported Python versions:
1212
- Python 2.7
1313
- Python 3.4+
1414

15-
To use these SDKs, you will need App SID and App Key which can be looked up at [Aspose Cloud Dashboard](https://dashboard.aspose.cloud/#/apps) (free registration in Aspose Cloud is required for this).
15+
To use these SDKs, you will need Client Id and Client Secret which can be looked up at [Aspose Cloud Dashboard](https://dashboard.aspose.cloud/applications) (free registration in Aspose Cloud is required for this).
1616

1717
## How to use the SDK
1818

1919
The complete source code is available in this repository folder. You can either directly use it in your project via source code or get [from PyPi](https://pypi.org/project/aspose-barcode-cloud/) (recommended).
2020

2121
## Prerequisites
2222

23-
To use Aspose.BarCode Cloud SDK for Python you need to register an account with [Aspose Cloud](https://www.aspose.cloud/) and lookup/create App Key and SID at [Cloud Dashboard](https://dashboard.aspose.cloud/#/apps). There is free quota available. For more details, see [Aspose Cloud Pricing](https://purchase.aspose.cloud/pricing).
23+
To use Aspose.BarCode Cloud SDK for Python you need to register an account with [Aspose Cloud](https://www.aspose.cloud/) and lookup/create Client Secret and Client Id at [Cloud Dashboard](https://dashboard.aspose.cloud/applications). There is free quota available. For more details, see [Aspose Cloud Pricing](https://purchase.aspose.cloud/pricing).
2424

2525
## Installation
2626

@@ -52,8 +52,8 @@ from aspose_barcode_cloud.rest import ApiException
5252

5353
# Configure OAuth2 access token for authorization: JWT
5454
configuration = aspose_barcode_cloud.Configuration(
55-
app_sid="App SID from https://dashboard.aspose.cloud/#/apps",
56-
app_key="App Key from https://dashboard.aspose.cloud/#/apps",
55+
client_id="Client Id from https://dashboard.aspose.cloud/applications",
56+
client_secret="Client Secret from https://dashboard.aspose.cloud/applications",
5757
)
5858

5959
# create an instance of the API class

aspose_barcode_cloud/api_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,12 @@ def __init__(self, configuration=None, header_name=None, header_value=None, cook
8282
# Use the pool property to lazily initialize the ThreadPool.
8383
self._pool = None
8484
self.rest_client = rest.RESTClientObject(configuration)
85-
self.default_headers = {"x-aspose-client": "python sdk", "x-aspose-client-version": "20.10.0"}
85+
self.default_headers = {"x-aspose-client": "python sdk", "x-aspose-client-version": "20.11.0"}
8686
if header_name is not None:
8787
self.default_headers[header_name] = header_value
8888
self.cookie = cookie
8989
# Set default User-Agent.
90-
self.user_agent = "Aspose-Barcode-SDK/20.10.0/python"
90+
self.user_agent = "Aspose-Barcode-SDK/20.11.0/python"
9191

9292
def __del__(self):
9393
if self._pool is not None:

aspose_barcode_cloud/configuration.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ class Configuration(object):
5050

5151
def __init__(
5252
self,
53-
app_sid=None,
54-
app_key=None,
53+
client_id=None,
54+
client_secret=None,
5555
access_token=None,
5656
host=None,
5757
token_url="https://api.aspose.cloud/connect/token",
@@ -81,8 +81,8 @@ def __init__(
8181

8282
# access token for OAuth
8383
self._access_token = access_token
84-
self._app_sid = app_sid
85-
self._app_key = app_key
84+
self._client_id = client_id
85+
self._client_secret = client_secret
8686
self._token_url = token_url
8787

8888
# Logging Settings
@@ -131,11 +131,11 @@ def access_token(self):
131131
if self._access_token:
132132
return self._access_token
133133

134-
if self._app_sid and self._app_key and self._token_url:
135-
self._access_token = self.fetch_token(self._app_sid, self._app_key, self._token_url)
134+
if self._client_id and self._client_secret and self._token_url:
135+
self._access_token = self.fetch_token(self._client_id, self._client_secret, self._token_url)
136136
return self._access_token
137137

138-
raise ValueError("No access_token or app_sid and app_key specified")
138+
raise ValueError("No access_token or client_id and client_secret specified")
139139

140140
@property
141141
def token_url(self):
@@ -285,16 +285,16 @@ def to_debug_report(self):
285285
"OS: {env}\n"
286286
"Python Version: {pyversion}\n"
287287
"Version of the API: 3.0\n"
288-
"SDK Package Version: 20.10.0".format(env=sys.platform, pyversion=sys.version)
288+
"SDK Package Version: 20.11.0".format(env=sys.platform, pyversion=sys.version)
289289
)
290290

291291
@staticmethod
292-
def fetch_token(app_sid, app_key, token_url):
293-
client = RESTClientObject(Configuration(app_sid=app_sid, app_key=app_key, token_url=token_url))
292+
def fetch_token(client_id, client_secret, token_url):
293+
client = RESTClientObject(Configuration(client_id=client_id, client_secret=client_secret, token_url=token_url))
294294
response = client.POST(
295295
token_url,
296296
headers={"Content-Type": "application/x-www-form-urlencoded"},
297-
post_params={"grant_type": "client_credentials", "client_id": app_sid, "client_secret": app_key},
297+
post_params={"grant_type": "client_credentials", "client_id": client_id, "client_secret": client_secret},
298298
)
299299
js_data = json.loads(response.data)
300300
access_token = js_data["access_token"]

example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
from aspose_barcode_cloud import BarcodeApi, ApiClient, Configuration, EncodeBarcodeType, PresetType
77

88
config = Configuration(
9-
app_sid="App SID from https://dashboard.aspose.cloud/#/apps",
10-
app_key="App Key from https://dashboard.aspose.cloud/#/apps",
9+
client_id="Client Id from https://dashboard.aspose.cloud/applications",
10+
client_secret="Client Secret from https://dashboard.aspose.cloud/applications",
1111
access_token=os.environ.get("TEST_ACCESS_TOKEN") # Only for testing in CI, remove this line
1212
)
1313

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
from setuptools import setup, find_packages
3030

3131
NAME = "aspose-barcode-cloud"
32-
VERSION = "20.10.0"
32+
VERSION = "20.11.0"
3333
# To install the library, run the following
3434
#
3535
# python setup.py install

tests/configuration.example.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"access_token": "JWT token",
3-
"app_sid": "App SID from https://dashboard.aspose.cloud/#/apps",
4-
"app_key": "App Key from https://dashboard.aspose.cloud/#/apps",
3+
"client_id": "Client Id from https://dashboard.aspose.cloud/applications",
4+
"client_secret": "Client Secret from https://dashboard.aspose.cloud/applications",
55
"host": "https://api.aspose.cloud/v3.0",
66
"token_url": "https://api.aspose.cloud/connect/token"
77
}

tests/test_auth.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
from .load_configuration import TEST_CONFIGURATION
77

88

9-
@unittest.skipUnless(TEST_CONFIGURATION._app_sid and TEST_CONFIGURATION._app_key, "No app_sid and app_key provided")
9+
@unittest.skipUnless(
10+
TEST_CONFIGURATION._client_id and TEST_CONFIGURATION._client_secret, "No client_id and client_secret provided"
11+
)
1012
class TestAuth(unittest.TestCase):
1113
@classmethod
1214
def setUpClass(cls):
@@ -23,7 +25,7 @@ def test_access_token_raises(self):
2325
with self.assertRaises(ValueError) as cm:
2426
_ = config.access_token
2527
the_exception = cm.exception
26-
self.assertEqual("No access_token or app_sid and app_key specified", the_exception.args[0])
28+
self.assertEqual("No access_token or client_id and client_secret specified", the_exception.args[0])
2729

2830
def test_works_with_access_token(self):
2931
api = BarcodeApi(
@@ -33,7 +35,7 @@ def test_works_with_access_token(self):
3335
self.assertEqual(200, response.status)
3436

3537
def test_unauthorized_raises(self):
36-
api = BarcodeApi(ApiClient(Configuration(access_token="incorrect token")))
38+
api = BarcodeApi(ApiClient(Configuration(access_token="incorrect token", host=TEST_CONFIGURATION.host)))
3739

3840
with self.assertRaises(Exception) as context:
3941
api.get_barcode_generate(EncodeBarcodeType.QR, "Testing")

tests/test_headers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ def test_default_headers(self):
2424

2525
self.assertEqual(1, self.rest_client_mock.GET.call_count)
2626
headers = self.rest_client_mock.GET.call_args[1]["headers"]
27-
self.assertEqual("Aspose-Barcode-SDK/20.10.0/python", headers["User-Agent"])
27+
self.assertEqual("Aspose-Barcode-SDK/20.11.0/python", headers["User-Agent"])
2828
self.assertEqual("python sdk", headers["x-aspose-client"])
29-
self.assertEqual("20.10.0", headers["x-aspose-client-version"])
29+
self.assertEqual("20.11.0", headers["x-aspose-client-version"])
3030

3131
def test_header_override(self):
3232
api_client = ApiClient(self.local_config, header_name="x-aspose-client", header_value="some custom sdk")

0 commit comments

Comments
 (0)