-
Notifications
You must be signed in to change notification settings - Fork 35
@W-9746696 refresh token logic for falcon added #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
vmeena0418
wants to merge
7
commits into
salesforce:master
Choose a base branch
from
vmeena0418:refreshToken
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
543b42c
refresh token logic for falcon added
vmeena0418 e2249bd
added parameted def
vmeena0418 9c3c5f8
Update argusclient/client.py
vmeena0418 e80ef68
Update argusclient/client.py
vmeena0418 4cdb00b
Update argusclient/client.py
vmeena0418 456f1eb
Update argusclient/client.py
vmeena0418 8412c4d
updating method call
vmeena0418 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -695,6 +695,9 @@ def with_auth_token(*args, **kwargs): | |||||
except ArgusAuthException: | ||||||
if argus.password: | ||||||
logging.debug("Token refresh failed, will attempt a fresh login", exc_info=True) | ||||||
if argus.falconEnv: | ||||||
logging.debug("Access Token and Refresh Token expired, update token files and provide relevant path") | ||||||
argus.refreshToken, argus.accessToken = getTokensFromFiles() | ||||||
else: | ||||||
raise | ||||||
if not argus.accessToken and argus.password: | ||||||
|
@@ -712,6 +715,18 @@ def with_auth_token(*args, **kwargs): | |||||
|
||||||
return with_auth_token | ||||||
|
||||||
# Updates Access token and refresh token from files for mac to falcon usecase | ||||||
vmeena0418 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
def getTokensFromFiles(): | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. update method calls as well |
||||||
# Prompt for access token | ||||||
filepath = raw_input("Provide path to access token file") | ||||||
vmeena0418 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
with open(filepath, 'r') as f: | ||||||
access_token = f.read() | ||||||
|
||||||
# Prompt for refresh token | ||||||
filepath = raw_input("Provide path to refresh token file") | ||||||
vmeena0418 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
with open(filepath, 'r') as f: | ||||||
refresh_token = f.read() | ||||||
return access_token, refresh_token | ||||||
|
||||||
class ArgusServiceClient(object): | ||||||
""" | ||||||
|
@@ -763,7 +778,7 @@ class ArgusServiceClient(object): | |||||
|
||||||
""" | ||||||
|
||||||
def __init__(self, user, password, endpoint, timeout=(10, 120), refreshToken=None, accessToken=None): | ||||||
def __init__(self, user, password, endpoint, timeout=(10, 120), refreshToken=None, accessToken=None, falconEnv=False): | ||||||
""" | ||||||
Creates a new client object to interface with the Argus RESTful API. | ||||||
|
||||||
|
@@ -779,6 +794,8 @@ def __init__(self, user, password, endpoint, timeout=(10, 120), refreshToken=Non | |||||
:type refreshToken: str | ||||||
:param accessToken: A token that can be used to authenticate with Argus. If a ``refreshToken`` or ``password`` is specified, the ``accessToken`` will be refreshed as and when it is needed. | ||||||
:type refreshToken: str | ||||||
:param falconEnv: is falcon environment | ||||||
:type falconEnv: bool | ||||||
""" | ||||||
if not user: | ||||||
raise ValueError("A valid user must be specified") | ||||||
|
@@ -788,6 +805,7 @@ def __init__(self, user, password, endpoint, timeout=(10, 120), refreshToken=Non | |||||
raise ValueError("Need a valid Argus endpoint URL") | ||||||
|
||||||
self.user = user | ||||||
self.falconEnv = falconEnv | ||||||
self.password = password | ||||||
self.endpoint = endpoint | ||||||
self.timeout = timeout | ||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.