Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auth based on session token #17

Open
reach4bawer opened this issue Feb 18, 2021 · 1 comment
Open

Auth based on session token #17

reach4bawer opened this issue Feb 18, 2021 · 1 comment

Comments

@reach4bawer
Copy link

Is it possible to use the session token that I have obtained using a different mechanism (cannot obtain it via the username and password because of organization having SSO) to be used with aiosfstream? I went through the docs but couldn't find it.

@caseyzak24
Copy link

I solved this problem by subclassing the AutheticatorBase class and creating a PassThroughAuthenticator. If this is something that @robertmrk thinks would be useful, I can try to submit a PR:

from aiosfstream.auth import AuthenticatorBase

class PassThruAuthenticator(AuthenticatorBase):

    def __init__(self, access_token, token_type, instance_url, id_, signature, issued_at, json_dumps=json.dumps,
                 json_loads=json.loads) -> None:
        super().__init__(json_dumps=json_dumps, json_loads=json_loads)
        self.access_token = access_token
        self.token_type = token_type
        self.instance_url = instance_url
        self.id = id_
        self.signature = signature
        self.issued_at = issued_at

    async def authenticate(self) -> None:
        pass

    async def _authenticate(self):
        pass

and then use as follows:

from aiosfstream import Client

stream_client = Client(authenticator=PassThruAuthenticator(...), ...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants