Skip to content

Instantly share code, notes, and snippets.

@jstacoder
Created November 24, 2014 09:04
Show Gist options
  • Save jstacoder/5823c8ad6eb1860da49a to your computer and use it in GitHub Desktop.
Save jstacoder/5823c8ad6eb1860da49a to your computer and use it in GitHub Desktop.
Simple Basecamp Authorization with python
from requests import Session # get the class to subclass
# setup your variables in the class
class BasecampSession(Session):
_username = ''
_password = ''
_basecamp_account_number = ''
_basecamp_api_url = 'https://basecamp.com/{}/api/v1/'
def __init__(username,password,bc_account_number,*args,**kwargs):
self._username = username
self._password = password
self._basecamp_account_number = bc_account_number
self.auth = (
self._username,
self._password
)
self._base_url = self._basecamp_api_url.format(
self._basecamp_account_number
)
super(BasecampSession,self).__init__(*args,**kwargs)
def get(self,url,*args,**kwargs):
url = self._base_url + url
return super(BasecampSession,self).get(*args,**kwargs)
@jstacoder
Copy link
Author

just make requests to the basecamp api endpoints

ex:
to get your info:

s = BasecampSession(username='xxx,password='xxx',bc_account_number='xxx')
s.get('users/me')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment