Skip to content
This repository was archived by the owner on May 5, 2025. It is now read-only.

Commit 8b140fd

Browse files
authored
Merge pull request #53 from sserrata/release-1.2.0
Release 1.2.0
2 parents 487b860 + 1e41eca commit 8b140fd

File tree

7 files changed

+127
-86
lines changed

7 files changed

+127
-86
lines changed

HISTORY.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@
22
History
33
=======
44

5+
1.2.0 (2018-06-20)
6+
------------------
7+
8+
* Updated README.rst
9+
* Updated RTD API Reference.
10+
* Added `pancloud` to requirements_dev.txt
11+
* Added docstrings to `Credentials` property methods.
12+
* Changed logging xpoll() to return entire log entry instead of just `_source` dictionary.
13+
* Added `Credentials` Storage Adapter feature and moved `TinyDB` code to `tinydb_adapter.py`, the default storage adapter.
14+
* Automatically carry `queryId` from `logging --query` response to `--id` in subsequent `--poll`, `--xpoll` and `--delete` in `summit.py`.
15+
* Various bug fixes and improvements to `summit.py`.
16+
* Added support for caching `access_token` in credentials store.
17+
* Added `write()` method to `LoggingService` class to support writing logs.
18+
* Fixed issues with `Credentials` `get_authorization_url` and `fetch_tokens` methods.
19+
* Added `logging_write.py` to examples.
20+
521
1.1.0 (2018-05-08)
622
------------------
723

Pipfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Sphinx = ">=\"1.4.8\""
1313
PyYAML = ">=\"3.11\""
1414
pytest = ">=\"2.9.2\""
1515
pytest-runner = ">=\"2.11.1\""
16+
sphinxcontrib-napoleon = "*"
1617

1718
[packages]
1819
requests = "*"

Pipfile.lock

Lines changed: 89 additions & 75 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pancloud/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
from .credentials import Credentials
1212

1313
__author__ = 'Palo Alto Networks'
14-
__version__ = '1.1.0'
14+
__version__ = '1.2.0'

pancloud/credentials.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,24 +160,32 @@ def _resolve_credential(self, credential):
160160
credential=credential, profile=self.profile
161161
)
162162

163-
def fetch_tokens(self, code=None, redirect_uri=None):
163+
def fetch_tokens(self, client_id=None, client_secret=None, code=None,
164+
redirect_uri=None):
164165
"""Fetch tokens from token URL.
165166
166167
Args:
168+
client_id (str): OAuth2 client ID. Defaults to ``None``.
169+
client_secret (str): OAuth2 client secret. Defaults to ``None``.
167170
code (str): Authorization code. Defaults to ``None``.
168171
redirect_uri (str): Redirect URI. Defaults to ``None``.
169172
170173
Returns:
171174
dict: Response from token URL.
172175
173176
"""
177+
client_id = client_id or self.client_id
178+
client_secret = client_secret or self.client_secret
174179
redirect_uri = redirect_uri or self.redirect_uri
175-
c = self.get_credentials()
176180
r = requests.post(
177181
self.token_url,
182+
headers={
183+
'Content-Type': 'application/x-www-form-urlencoded'
184+
},
178185
data={
179-
'client_id': c.client_id,
180-
'client_secret': c.client_secret,
186+
'grant_type': 'authorization_code',
187+
'client_id': client_id,
188+
'client_secret': client_secret,
181189
'code': code,
182190
'redirect_uri': redirect_uri
183191
},
@@ -202,11 +210,13 @@ def fetch_tokens(self, code=None, redirect_uri=None):
202210
raise PanCloudError(r.text)
203211
return r.json()
204212

205-
def get_authorization_url(self, instance_id=None, redirect_uri=None,
206-
region=None, scope=None, state=None):
213+
def get_authorization_url(self, client_id=None, instance_id=None,
214+
redirect_uri=None, region=None, scope=None,
215+
state=None):
207216
"""Generate authorization URL.
208217
209218
Args:
219+
client_id (str): OAuth2 client ID. Defaults to ``None``.
210220
instance_id (str): App Instance ID. Defaults to ``None``.
211221
redirect_uri (str): Redirect URI. Defaults to ``None``.
212222
region (str): App Region. Defaults to ``None``.
@@ -217,17 +227,17 @@ def get_authorization_url(self, instance_id=None, redirect_uri=None,
217227
str, str: Auth URL, state
218228
219229
"""
230+
client_id = client_id or self.client_id
220231
instance_id = instance_id or self.instance_id
221232
redirect_uri = redirect_uri or self.redirect_uri
222233
region = region or self.region
223234
scope = scope or self.scope
224235
state = state or self.state
225-
c = self.get_credentials()
226236
return requests.Request(
227237
'GET',
228238
self.auth_base_url,
229239
params={
230-
'client_id': c.client_id,
240+
'client_id': client_id,
231241
'instance_id': instance_id,
232242
'redirect_uri': redirect_uri,
233243
'region': region,

0 commit comments

Comments
 (0)