diff --git a/awx/api/authentication.py b/awx/api/authentication.py index f0d345e444..8ba8e11d34 100644 --- a/awx/api/authentication.py +++ b/awx/api/authentication.py @@ -46,14 +46,17 @@ class SessionAuthentication(authentication.SessionAuthentication): class LoggedOAuth2Authentication(OAuth2Authentication): def authenticate(self, request): - ret = super(LoggedOAuth2Authentication, self).authenticate(request) - if ret: - user, token = ret - username = user.username if user else '' - logger.info(smart_text( - u"User {} performed a {} to {} through the API using OAuth token {}.".format( - username, request.method, request.path, token.pk - ) - )) - setattr(user, 'oauth_scopes', [x for x in token.scope.split() if x]) - return ret + if 'Bearer' in request.META['HTTP_AUTHORIZATION']: + ret = super(LoggedOAuth2Authentication, self).authenticate(request) + if ret: + user, token = ret + username = user.username if user else '' + logger.debug(smart_text( + u"User {} performed a {} to {} through the API using OAuth token {}.".format( + username, request.method, request.path, token.pk + ) + )) + setattr(user, 'oauth_scopes', [x for x in token.scope.split() if x]) + return ret + else: + return None