caterva2.api_utils.get_auth_cookie#
- caterva2.api_utils.get_auth_cookie(urlbase, user_auth, server=None)#
Authenticate to a subscriber as a user and get an authorization cookie.
Authentication fields will usually be
username
andpassword
.- Parameters:
- Returns:
An authentication token that may be used as a cookie in further requests to the subscriber.
- Return type:
str
Examples
>>> import caterva2 as cat2 >>> urlbase = 'https://cat2.cloud/demo' >>> auth_cookie = cat2.get_auth_cookie(urlbase, dict(username='user@example.com', password='foo')) >>> cat2.upload('root-example/ds-sc-attr.b2nd', '@personal/attr.b2nd', urlbase, auth_cookie) PosixPath('@personal/attr.b2nd')