def signed_session(self):
        basic_authentication = BasicTokenAuthentication({"access_token": self.get_access_token()})
        session = basic_authentication.signed_session()

        # If there is no microsoft_app_id and no self.microsoft_app_password, then there shouldn't
        # be an "Authorization" header on the outgoing activity.
        if not self.microsoft_app_id and not self.microsoft_app_password:
            del session.headers['Authorization']
        return session
Пример #2
0
    def test_basic_token_auth(self):

        token = {'access_token': '123456789'}
        basic = BasicTokenAuthentication(token)
        basic.set_token()  # Just check that this does not raise
        session = basic.signed_session()

        req = session.prepare_request(self.request)
        assert 'Authorization' in req.headers
        assert req.headers['Authorization'] == 'Bearer 123456789'
    def signed_session(self) -> requests.Session:  # pylint: disable=arguments-differ
        """
        Gets the signed session.
        :returns: Signed requests.Session object
        """
        auth_token = self.get_access_token()

        basic_authentication = BasicTokenAuthentication({"access_token": auth_token})
        session = basic_authentication.signed_session()

        # If there is no microsoft_app_id and no self.microsoft_app_password, then there shouldn't
        # be an "Authorization" header on the outgoing activity.
        if not self.microsoft_app_id and not self.microsoft_app_password:
            del session.headers["Authorization"]
        return session
    def signed_session(self) -> requests.Session:
        """
        Gets the signed session.
        :returns: Signed requests.Session object
        """
        auth_token = asyncio.ensure_future(self.get_access_token())

        basic_authentication = BasicTokenAuthentication({"access_token": auth_token})
        session = basic_authentication.signed_session()

        # If there is no microsoft_app_id and no self.microsoft_app_password, then there shouldn't
        # be an "Authorization" header on the outgoing activity.
        if not self.microsoft_app_id and not self.microsoft_app_password:
            del session.headers['Authorization']
        return session
 def signed_session(self):
     basic_authentication = BasicTokenAuthentication(
         {"access_token": self.get_access_token()})
     return basic_authentication.signed_session()
Пример #6
0
 def signed_session(self, session=None):
     basic_authentication = BasicTokenAuthentication(
         {"access_token": self.access_token})
     return session or basic_authentication.signed_session()