To setup kerberos auth:
>>> import requests
>>> session = requests.Session()
>>> session.auth = beanbag.KerbAuth()
>>> foo = beanbag.BeanBag("http://hostname/api/", session=session)
Helper class for basic Kerberos authentication using requests library. A single instance can be used for multiple sites. Each request to the same site will use the same authorization token for a period of 180 seconds.
Example: |
---|
>>> session = requests.Session()
>>> session.auth = KerbAuth()
OAuth10aDance helps with determining the user creds, compared to using OAuth1 directly.
Create an OAuth10aDance object to negotiatie OAuth 1.0a credentials.
The first set of parameters are the URLs to the OAuth 1.0a service you wish to authenticate against.
Parameters: |
|
---|
These parameters (and the others) may also be provided by subclassing the OAuth10aDance class, eg:
Example: |
---|
>>> class OAuthDanceTwitter(beanbag.OAuth10aDance):
... req_token = "https://api.twitter.com/oauth/request_token"
... authorize = "https://api.twitter.com/oauth/authorize"
... acc_token = "https://api.twitter.com/oauth/access_token"
The second set of parameters identify the client application to the server, and need to be obtained outside of the OAuth protocol.
Parameters: |
|
---|
The final set of parameters identify the user to server. These may be left as None, and obtained using the OAuth 1.0a protocol via the obtain_creds() method or using the get_auth_url() and verify_user() methods.
Parameters: |
|
---|
Assuming OAuthDanceTwitter is defined as above, and you have obtained the client key and secret (see https://apps.twitter.com/ for twitter) as k and s, then putting these together looks like:
Example: |
---|
>>> oauthdance = OAuthDanceTwitter(client_key=k, client_secret=s)
>>> oauthdance.obtain_creds()
Please go to url:
https://api.twitter.com/oauth/authorize?oauth_token=...
Please input the verifier: 1111111
>>> session = requests.Session()
>>> session.auth = oauthdance.oauth()
Check whether all credentials are filled in
URL for user to obtain verification code
Set user key and secret based on verification code
Fill in credentials by interacting with the user (input/print)
Create an OAuth1 authenticator using client and user credentials