mirror of
https://github.com/ansible/awx.git
synced 2026-03-09 05:29:26 -02:30
Fixing oauth token login and making module respect token over username/password
This commit is contained in:
@@ -31,9 +31,12 @@ class TowerAWXKitModule(TowerModule):
|
|||||||
|
|
||||||
def authenticate(self):
|
def authenticate(self):
|
||||||
try:
|
try:
|
||||||
self.connection.login(username=self.username, password=self.password, token=self.oauth_token)
|
if self.oauth_token:
|
||||||
# If we have neither of these, then we can try un-authenticated access
|
self.connection.login(None, None, token=self.oauth_token, auth_type='Bearer')
|
||||||
self.authenticated = True
|
self.authenticated = True
|
||||||
|
elif self.username:
|
||||||
|
self.connection.login(username=self.username, password=self.password)
|
||||||
|
self.authenticated = True
|
||||||
except Exception:
|
except Exception:
|
||||||
self.exit_json("Failed to authenticate")
|
self.exit_json("Failed to authenticate")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user