Fixing oauth token login and making module respect token over username/password

This commit is contained in:
John Westcott IV 2020-08-19 12:18:07 -04:00
parent a2eab45d61
commit 3abd77c4c0

View File

@ -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")