Created
November 24, 2014 09:04
-
-
Save jstacoder/5823c8ad6eb1860da49a to your computer and use it in GitHub Desktop.
Simple Basecamp Authorization with python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
just make requests to the basecamp api endpoints
ex:
to get your info: