Skip to content

Commit

Permalink
Added debugging functionality to token_authentication_example.py and …
Browse files Browse the repository at this point in the history
…also icluded region selection, related to #1181
  • Loading branch information
okewoma authored and jshcodes committed Jul 18, 2024
1 parent 6ce5926 commit 4cb4aad
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions samples/authentication/token_authentication_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,16 @@ def consume_arguments() -> Namespace:
dest="base_url",
help="CrowdStrike cloud region. (auto or usgov1, Default: auto)",
required=False,
default="auto"
default="usgov1"
)
return parser.parse_args
parsed = parser.parse_args()
if parsed.debug:
logging.basicConfig(level=logging.DEBUG)


return parsed
# ### BEGIN token simulation
def get_token():
def get_token(debug=False):
"""
Generate a token to use for authentication.
Expand Down Expand Up @@ -111,7 +115,8 @@ def get_token():
)
auth = OAuth2(
client_id=falcon_client_id,
client_secret=falcon_client_secret
client_secret=falcon_client_secret,
debug=debug
)
# Generate a token
auth.token()
Expand Down Expand Up @@ -192,6 +197,10 @@ def passed(svc_class: str):


if __name__ == "__main__":
# Parse command-line arguments and retrieve debug mode setting
args = consume_arguments()
# Authenticate using Falcon API OAuth2 with debug mode enabled if specified
get_token(debug=args.debug)
# Test each of these classes to confirm cross collection authentication for Service Classes
classes_to_test = [CloudConnectAWS, Detects, Hosts, IOC, Incidents, Intel]
# Grab a simulated token and execute the test series
Expand Down

0 comments on commit 4cb4aad

Please sign in to comment.