You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 17, 2019. It is now read-only.
requests-crtauth works as an authentication plugin for Python Requests. See the authentication documentation for more details. The following arguments may be provided to a new instance of HttpCrtAuth:
username: User to authenticate as. Defaults to $USER.
private_key: A PEM encoded private key string. Overrides signer.
signer: A crtauth SigningPlug instance. Defaults to using the SSH agent (AgentSigner).
version: Integer version of the crtauth protocol. Defaults to version 1.
Here's an example.
In [1]: importrequests, requests_crtauth, json, loggingIn [2]: logging.basicConfig(level=logging.DEBUG)
In [3]: session=requests.Session()
# HttpCrtAuth() will default to authenticating with your $USER env variable and a key from your SSH agent.# To specify an explicit key: requests_crtauth.HttpCrtAuth(username='negz', private_key='key data as a string')In [4]: session.auth=requests_crtauth.HttpCrtAuth()
In [5]: data=json.dumps({'comment': 'I\'m a comment!'})
In [6]: headers= {'content-type': 'application/json; charset=utf-8'}
In [7]: response=session.put('https://db.spotify.net/v1/things/yomaris', data=data, headers=headers)
INFO:requests.packages.urllib3.connectionpool:StartingnewHTTPSconnection (1): db.spotify.netDEBUG:requests.packages.urllib3.connectionpool:"PUT /v1/things/yomaris HTTP/1.1"40112DEBUG:root:SendingchallengerequestDEBUG:requests.packages.urllib3.connectionpool:"HEAD /_auth HTTP/1.1"2000DEBUG:root:SendingresponsetochallengeREDACTEDDEBUG:requests.packages.urllib3.connectionpool:"HEAD /_auth HTTP/1.1"2000DEBUG:root:StoredCHAPtokenREDACTEDDEBUG:root:UsingnewlystoredCHAPtoken.
DEBUG:requests.packages.urllib3.connectionpool:"PUT /v1/things/yomaris HTTP/1.1"200NoneIn [8]: response.okOut[8]: True
About
A crtauth authentication plugin for Python Requests