From 3abd77c4c02a29f68d2148a317bb0c8cf6c99a23 Mon Sep 17 00:00:00 2001 From: John Westcott IV Date: Wed, 19 Aug 2020 12:18:07 -0400 Subject: [PATCH] Fixing oauth token login and making module respect token over username/password --- awx_collection/plugins/module_utils/tower_awxkit.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/awx_collection/plugins/module_utils/tower_awxkit.py b/awx_collection/plugins/module_utils/tower_awxkit.py index ddd2d190c7..506b64fb20 100644 --- a/awx_collection/plugins/module_utils/tower_awxkit.py +++ b/awx_collection/plugins/module_utils/tower_awxkit.py @@ -31,9 +31,12 @@ class TowerAWXKitModule(TowerModule): def authenticate(self): try: - self.connection.login(username=self.username, password=self.password, token=self.oauth_token) - # If we have neither of these, then we can try un-authenticated access - self.authenticated = True + if self.oauth_token: + self.connection.login(None, None, token=self.oauth_token, auth_type='Bearer') + self.authenticated = True + elif self.username: + self.connection.login(username=self.username, password=self.password) + self.authenticated = True except Exception: self.exit_json("Failed to authenticate")