Skip to content

Commit 93e81aa

Browse files
committed
make bearer auth per session intead of per req
1 parent 7bb9334 commit 93e81aa

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

reportportal_client/service.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,8 @@
11
import requests
2-
from requests.auth import AuthBase
32

43
from .model import (EntryCreatedRS, OperationCompletionRS)
54

65

7-
class BearerAuth(AuthBase):
8-
"""Attaches HTTP Bearer Authentication to the given Request object."""
9-
def __init__(self, token):
10-
self.token = token
11-
12-
def __call__(self, r):
13-
r.headers["Authorization"] = "bearer {0}".format(self.token)
14-
return r
15-
16-
176
class ReportPortalService(object):
187
"""Service class with report portal event callbacks."""
198

@@ -35,8 +24,9 @@ def __init__(self, endpoint, project, token, api_base=None):
3524
self.base_url = self.uri_join(self.endpoint,
3625
self.api_base,
3726
self.project)
27+
3828
self.session = requests.Session()
39-
self.session.auth = BearerAuth(self.token)
29+
self.session.headers["Authorization"] = "bearer {0}".format(self.token)
4030

4131
@staticmethod
4232
def uri_join(*uri_parts):

0 commit comments

Comments
 (0)