billdeitrick / pypco

A Python client for the Planning Center Online API.
MIT License
39 stars 13 forks source link

Add support for OrganizationToken type authentication #50

Closed pastorhudson closed 1 year ago

pastorhudson commented 2 years ago

The api.churchcenter.com endpoint uses

'Authorization': f'OrganizationToken {token}' as the authentication scheme. This pull request adds org_token as an optional argument to setting up PCO object.

It also adds PCOAuthType.ORGTOKEN

I've tested it and it works with api.churchcenter.com OrganizationTokens.

pastorhudson commented 2 years ago

@billdeitrick Can you give this a glance and see if I missed anything?

pastorhudson commented 2 years ago

I added a helper to get a church center org token from a church center vanity url.

billdeitrick commented 2 years ago

@pastorhudson Great work! I'd like to get unit tests on this before we merge it in. I'm happy to look at this when possible (would likely be the next couple of weeks), but if you'd be willing to add that would be fine too!

pastorhudson commented 2 years ago

How should I do unit tests? Do I just pick a church center url to test against? Check for token, and then make a request to make sure it works?

pastorhudson commented 2 years ago

Ah I see test_auth_config.py I should be able to add the org_token just like the other auth's easy enough.

billdeitrick commented 2 years ago

We might as well update the docs too: https://github.com/billdeitrick/pypco/blob/master/docs/source/gettingstarted.md#authentication

I should have some time in the next day or two to look over this more carefully and will get it merged in. I'll update the docs while I'm at it (which will make sure I know how this works. 🙂).

I'm thinking we can release this as well as a fix for #45 as v1.2.0.

pastorhudson commented 2 years ago

Ok I'm working on the mock response code to test getting a org_token

codecov[bot] commented 2 years ago

Codecov Report

Merging #50 (ebd360d) into master (ad6ca5a) will not change coverage. The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master       #50   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            5         5           
  Lines          175       198   +23     
=========================================
+ Hits           175       198   +23     
Impacted Files Coverage Δ
pypco/auth_config.py 100.00% <100.00%> (ø)
pypco/pco.py 100.00% <100.00%> (ø)
pypco/user_auth_helpers.py 100.00% <100.00%> (ø)

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

pastorhudson commented 2 years ago

Just bumping this. I think we're ready to merge

billdeitrick commented 1 year ago

@pastorhudson Sorry for the delay! I should have time to get this merged in tonight. I haven't had a chance to write up some documentation so I'll open an issue for getting this documented and kick that can down the road... 😛