phistrom / basecampy3 Goto Github PK
View Code? Open in Web Editor NEWA Python API for Basecamp 3
License: MIT License
A Python API for Basecamp 3
License: MIT License
I was using some of the sample direct session code provided as I am trying to find a way to get different pages since the you only get 15 back at a time and the api docs mention its a paginated list.
url = bc3.urls.todos.list(sort='updated_at' , kwargs="page=2")
response = url.request(bc3.session)
response.json()
Which created close to the url that I think it should be based on the API docs. It builds this ULR: "https://3.basecampapi.com/{ID}/projects/recordings.json?type=Todo&status=active&sort=updated_at&direction=desc&kwargs=page%3D1" which does work to return a valid response but always page 1.
This code don't pass situation when conf is already loaded
if access_token or can_refresh_access_tokens or can_request_our_own_refresh_tokens:
conf = BasecampConfig(client_id=client_id, client_secret=client_secret, redirect_uri=redirect_uri,
user_email=user_email, user_pass=user_pass, access_token=access_token,
refresh_token=refresh_token, access_expires=access_expires)
elif conf is None:
conf = BasecampConfig.load_from_default_paths()
else:
raise ValueError("Need a valid BasecampConfig object, a refresh token, an access token, or enough "
"information to get our own refresh tokens (client_id, client_secret, redirect_uri, "
"username, and password)")
Hi, as shown in the following full dependency graph of basecampy3r, basecampy3r requires chardet * , while the installed version of requests(2.22.0) requires chardet <3.1.0,>=3.0.2.
According to Pip's “first found wins” installation strategy, chardet 3.0.4 is the actually installed version.
Although the first found package version chardet 3.0.4 just satisfies the later dependency constraint (chardet <3.1.0,>=3.0.2), it will lead to a build failure once developers release a newer version of chardet.
basecampy3r - 0.2.2
| +- beautifulsoup4(install version:4.8.1 version range:*)
| | +- soupsieve(install version:1.9.5 version range:>=1.2)
| +- certifi(install version:2019.9.11 version range:*)
| +- chardet(install version:3.0.4 version range:*)
| +- idna(install version:2.8 version range:*)
| +- python-dateutil(install version:2.8.1 version range:*)
| +- requests(install version:2.22.0 version range:*)
| | +- certifi(install version:2019.9.11 version range:>=2017.4.17)
| | +- chardet(install version:3.0.4 version range:<3.1.0,>=3.0.2)
| | +- idna(install version:2.8 version range:>=2.5,<2.9)
| | +- urllib3(install version:1.25.6 version range:<1.26,>=1.21.1)
| +- six(install version:1.13.0 version range:*)
| +- urllib3(install version:1.25.6 version range:*)
Thanks for your attention.
Best,
Neolith
It would be a good practice to switch to tests that use mock API instead of actual production API.
I noticed today that on September 9th, 2021 Basecamp announced support for multiple message boards, campfire chats, To-do Lists, Schedules, Automatic Check-ins, and Docs & Files per project. I will have to see if that functionality can be incorporated into BasecamPY3 without breaking existing code.
I think I want to start working towards a BasecamPY3 1.0.0 release that does the following:
async
and await
to speed some things up which means dropping Python versions below 3.5.Interestingly, no changes have been made to basecamp/bc3-api since the announcement of Basecamp 4. I'm wondering if they'll make a separate Basecamp 4 API or not.
Consider this a sort of request for comments.
Hi, as shown in the following full dependency graph of basecampy3r, basecampy3r requires idna * , while the installed version of requests(2.22.0) requires idna >=2.5,<2.9.
According to Pip's “first found wins” installation strategy, idna 2.8 is the actually installed version.
Although the first found package version idna 2.8 just satisfies the later dependency constraint (idna >=2.5,<2.9), it will lead to a build failure once developers release a newer version of idna.
basecampy3r - 0.2.2
| +- beautifulsoup4(install version:4.8.1 version range:*)
| | +- soupsieve(install version:1.9.5 version range:>=1.2)
| +- certifi(install version:2019.9.11 version range:*)
| +- chardet(install version:3.0.4 version range:*)
| +- idna(install version:2.8 version range:*)
| +- python-dateutil(install version:2.8.1 version range:*)
| +- requests(install version:2.22.0 version range:*)
| | +- certifi(install version:2019.9.11 version range:>=2017.4.17)
| | +- chardet(install version:3.0.4 version range:<3.1.0,>=3.0.2)
| | +- idna(install version:2.8 version range:>=2.5,<2.9)
| | +- urllib3(install version:1.25.6 version range:<1.26,>=1.21.1)
| +- six(install version:1.13.0 version range:*)
| +- urllib3(install version:1.25.6 version range:*)
Thanks for your attention.
Best,
Neolith
Hi again, @phistrom!
I'd love to also be able to grab the comments from the todo items, and it seems that comments are just attached to recordings on BC api, and I can put together a recording endpoint class for them.
I'd be happy to work on it and contribute to basecampy3 if that's fine and if you'll have 15 minutes to review the PR. Or maybe I'm missing something and there's a way to fetch comments with what's already in the library?
method save of class BasecampConfig fails if field filepath is None
this happens if object Basecamp3 is created from constructor without a command line configuration
recommend modification so method ignores saving if filepath is None.
if filepath is None:
filepath = self.filepath
if filepath is not None:
try:
[...]```
Looking at the bc3_api.py it would appear I should be able to pass in arguments to create a Basecamp3 object without the need for creating a configuration file first.
ie:
bc3 = Basecamp3(client_id='blahblahblah',
client_secret='blahblahblah',
redirect_uri='https://blah.com/auth',
refresh_token='blahblahblah'
)
When I try this I get the following error:
Traceback (most recent call last):
File "/Users/canders/Code/reports/basereport.py", line 109, in <module>
refresh_token='blahblahblah',
File "/Users/canders/Code/python3-testing/lib/python3.6/site-packages/basecampy3/bc3_api.py", line 110, in __init__
self._authorize()
File "/Users/canders/Code/python3-testing/lib/python3.6/site-packages/basecampy3/bc3_api.py", line 170, in _authorize
self._get_access_token()
File "/Users/canders/Code/python3-testing/lib/python3.6/site-packages/basecampy3/bc3_api.py", line 181, in _get_access_token
self._save_token_json(token_json)
File "/Users/canders/Code/python3-testing/lib/python3.6/site-packages/basecampy3/bc3_api.py", line 236, in _save_token_json
self._conf.save()
File "/Users/canders/Code/python3-testing/lib/python3.6/site-packages/basecampy3/config.py", line 78, in save
os.makedirs(os.path.dirname(filepath), mode=0o770)
File "/Users/canders/Code/python3-testing/bin/../lib/python3.6/posixpath.py", line 154, in dirname
p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not NoneType
Looks like you have logic that assumes we need to save these details which are then read when creating the API calls to basecamp?
Looking at:
bc3_api.py", line 236, in _save_token_json
config.py", line 78, in save
the problem looks to be that you are not passing in the filepath argument hence the NoneType... I assume this was an oversight as you have in the BasecampConfig constructor self.filepath defined.
Can I suggest that you update the constructor for the Basecamp3 class to include filepath to be passed in to _save_token_json OR could we look at making use of io.StringIO() so that we dont have to worry about saving a file when arguments are being passed in?
I like the second option so I could run this code in a container such as google's app engine :)
at constructor, if a config is passed,
if there is data to create a new config, a new config is created and argument is ignored
if there is no data to create a new config, but a config was passed in argument, error is raised
conf = BasecampConfig(client_id=client_id, client_secret=client_secret, redirect_uri=redirect_uri,
user_email=user_email, user_pass=user_pass, access_token=access_token,
refresh_token=refresh_token, access_expires=access_expires)
elif conf is None:
conf = BasecampConfig.load_from_default_paths()
else:
raise ValueError("Need a valid BasecampConfig object, a refresh token, an access token, or enough "
"information to get our own refresh tokens (client_id, client_secret, redirect_uri, "
"username, and password)")```
Hey @licht1stein and @phistrom!
I needed to bulk-export our data from Basecamp and upload it to Jira, found Basecampy, and built a small tool with it (https://github.com/nategadzhi/baseport). Just wanted to say thank you for all your time and effort that went into building it, it helped me a lot and saved us a ton of time. 👏
Thanks for this tool!
I'm not sure if this is on the Basecamp API side or the library, but booleans are returned capitalized, which isn't valid JSON. Also an empty field or one which doesn't exist should probably return an empty string (or null) rather than None which isn't valid JSON either. See https://www.json.org/json-en.html
im getting error
Traceback (most recent call last):
File "/usr/local/bin/bc3", line 11, in <module>
load_entry_point('basecampy3==0.2.2', 'console_scripts', 'bc3')()
File "/usr/local/lib/python2.7/dist-packages/basecampy3/bc3_cli.py", line 122, in main
return CLI.from_command_line()
File "/usr/local/lib/python2.7/dist-packages/basecampy3/bc3_cli.py", line 38, in from_command_line
args.func()
File "/usr/local/lib/python2.7/dist-packages/basecampy3/bc3_cli.py", line 61, in _configure
code = requestor.get_user_code()
File "/usr/local/lib/python2.7/dist-packages/basecampy3/token_requestor.py", line 53, in get_user_code
user_code = self._submit_authorize_app_form(login_resp.url, login_resp.text)
File "/usr/local/lib/python2.7/dist-packages/basecampy3/token_requestor.py", line 100, in _submit_authorize_app_form
auth_code = parse_qs(urlparse(app_redirect_uri).query)['code'][0]
KeyError: 'code'
I printed response and get google.api
https://accounts.google.com/o/oauth2/auth?client_id=341981671303-g568phroodi4guli3inqb7gnsvbvqnlk.apps.googleusercontent.com&prompt=login&redirect_uri=https%3A%2F%2Flaunchpad.37signals.com%2Fgoogle_sign_in%2Fcallback&response_type=code&scope=openid+profile+email&state=SyLv%2Bvf5g11LVk%2BGMlNWR1psf7Q%2Bnby5
When I try to configure using bc3 configure then it asks for client id and client secret upon entering which is required to enter email and passwords associated but the problem is I have my google account associated instead of normal email and password
Thus the authentication fails and configure is unsuccessful.
Obtaining your access key and refresh token...
Traceback (most recent call last):
File "C:\Users\Amartya\AppData\Local\Programs\Python\Python37-32\Scripts\bc3-script.py", line 11, in
load_entry_point('basecampy3==0.2.2', 'console_scripts', 'bc3')()
File "c:\users\amartya\appdata\local\programs\python\python37-32\lib\site-packages\basecampy3\bc3_cli.py", line 122, in main
return CLI.from_command_line()
File "c:\users\amartya\appdata\local\programs\python\python37-32\lib\site-packages\basecampy3\bc3_cli.py", line 38, in from_command_line
args.func()
File "c:\users\amartya\appdata\local\programs\python\python37-32\lib\site-packages\basecampy3\bc3_cli.py", line 61, in _configure
code = requestor.get_user_code()
File "c:\users\amartya\appdata\local\programs\python\python37-32\lib\site-packages\basecampy3\token_requestor.py", line 53, in get_user_code
user_code = self._submit_authorize_app_form(login_resp.url, login_resp.text)
File "c:\users\amartya\appdata\local\programs\python\python37-32\lib\site-packages\basecampy3\token_requestor.py", line 98, in _submit_authorize_app_form
auth_code = parse_qs(urlparse(app_redirect_uri).query)['code'][0]
KeyError: 'code'
In my project used different version of same depended packages.
And when im installing this package i get this error
pkg_resources.ContextualVersionConflict: (beautifulsoup4 4.6.3 (/opt/rp/env/lib/python2.7/site-packages), Requirement.parse('beautifulsoup4==4.6.0'), set(['basecampy3']))
May be its better to remove versions and leave them only in requirements.txt
install_requires=[
"beautifulsoup4",
"certifi",
"chardet",
"idna",
"python-dateutil",
"requests",
"six",
"urllib3",
],
When upgrading form 0.3.0 >> 0.6.0 the find function seems to have broke in the process.
I used to use
bc3.projects.find("Project Name')
in existing code which would return a list of matched project names but this seems to have broke with no other changes to the code after updating. And is returning an error "AttributeError: 'str' object has no attribute 'search' " Let me now if there's any additional info I can provide.
Sample Code:
from basecampy3 import Basecamp3
bc3 = Basecamp3()
find_project = bc3.projects.find('Test Project')
find_project[0]
Hi, as shown in the following full dependency graph of basecampy3r, basecampy3r requires urllib3 * , while the installed version of requests(2.22.0) requires urllib3 <1.26,>=1.21.1.
According to Pip's “first found wins” installation strategy, urllib3 1.25.7 is the actually installed version.
Although the first found package version urllib3 1.25.7 just satisfies the later dependency constraint (urllib3 <1.26,>=1.21.1), it will lead to a build failure once developers release a newer version of urllib3.
basecampy3r - 0.2.2
| +- beautifulsoup4(install version:4.8.1 version range:*)
| | +- soupsieve(install version:1.9.5 version range:>=1.2)
| +- certifi(install version:2019.9.11 version range:*)
| +- chardet(install version:3.0.4 version range:*)
| +- idna(install version:2.8 version range:*)
| +- python-dateutil(install version:2.8.1 version range:*)
| +- requests(install version:2.22.0 version range:*)
| | +- certifi(install version:2019.9.11 version range:>=2017.4.17)
| | +- chardet(install version:3.0.4 version range:<3.1.0,>=3.0.2)
| | +- idna(install version:2.8 version range:>=2.5,<2.9)
| | +- urllib3(install version:1.25.6 version range:<1.26,>=1.21.1)
| +- six(install version:1.13.0 version range:*)
| +- urllib3(install version:1.25.6 version range:*)
Thanks for your attention.
Best,
Neolith
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.