cronofy / pycronofy Goto Github PK
View Code? Open in Web Editor NEWA Python adapter for the Cronofy calendaring service
Home Page: https://docs.cronofy.com/developers
License: MIT License
A Python adapter for the Cronofy calendaring service
Home Page: https://docs.cronofy.com/developers
License: MIT License
I integrated cronofy on my system, but there is big challenge for me to refine calendars for each user.
Since there are many registered users, each of them connect his calendars and for saving their calendars in my db I hit list_calendars like:
for calendar in cronofy.list_calendars():
print(calendar)
It returns all connected calendars to my registered app on cronofy, but I need only calendar connected by that particular user?
How can I do that?
Thanks
The Cronofy documentation (https://docs.cronofy.com/developers/api/authorization/revoke/) gives the following advice for revoking authorization:
It is recommended that you use the refresh_token as that cannot have expired and therefore be impossible to revoke
The revoke function uses the access token instead:
Line 531 in 59765fe
Line 539 in 59765fe
This gives issues when the access token has expired.
Is there a specific reason the access token is used here?
pycronofy/tests/test_client.py::test_refresh
can fail when running with pytest --randomly-seed=1234
.
it would be nice if you could create a calendar with the client since the api supports it
Calling BatchBuilder#upsert_event
using datetimes for start
/end
throws a json serialization error, since the datetimes aren't formatted into strings
Client#batch
sends the batched requests directly as a list in the POST body, instead of providing an object with the list keyed under batch
as expected per docs, causing batched requests to fail.
Cronofy has the feature in their docs to create an event with:
The start time can be provided as a simple Time or Date string or an object with two attributes, time and tzid:
{
"time": "2014-08-05T17:00:00Z",
"tzid": "Europe/Paris"
}
It seems the dict
structure is not supported in upsert_event
for the start
and end
values.
Can't seem to get the results back in the right timezone even after setting it as required.
events = cronofy.read_events(calendar_ids=('CAL_ID',),from_date=from_date, to_date=to_date, tzid='Asia/Kolkata')
print (events.json())
The returning json always has events in the UTC timezone. Does it mean that tzid
is only for the input (from_date
, to_date
) and the returned values will always be in UTC?
(Also asked on SO but it doesn't seem to have a tag for Cronofy or this library)
Thanks for maintaining PyCronofy!
It would be awesome if this repo implemented MyPy type hints - currently I'm working on the generate_smart_invite
code and it would be nice to have type hinting on the input parameters and also nice to understand the shape of the return value via the type hint.
If not possible, then it would be almost as helpful to include the return value in the docstring.
One more helpful thing would be to include a Python version of how to send the base64-encoded attachment in the smart invite email docs.
Hi, i have two problems, the first is that when i execute the authentication request it doesn't prompt any link.
The second is that i don't know what kind of link i should put in the url variable.
if someone have any idea of what i'm missing i'll be very grateful
Not strictly this repo but needs to be completed for the milestone
Requests (and pytz) don't seem to be added to the dependencies when installing through pypi, causing errors if you don't have those packages already installed in your repo.
Exception trying to import pycronofy:
File "/path/to/user_code.py", line 5, in <module>
import pycronofy
File "/Users/......./python3.7/site-packages/pycronofy/__init__.py", line 1, in <module>
from pycronofy.client import Client # noqa: F401
File "/Users/......./python3.7/site-packages/pycronofy/client.py", line 12, in <module>
from pycronofy.request_handler import RequestHandler
File "/Users/......./python3.7/site-packages/pycronofy/request_handler.py", line 1, in <module>
import requests
ModuleNotFoundError: No module named 'requests'
Output from pipenv graph
:
PyCronofy==1.3.0
- future [required: Any, installed: 0.17.1]
Here's a small snippet to reproduce the error(replace the client id/secret)
import pycronofy
cronofy = pycronofy.Client(
client_id=CRONOFY_CLIENT_ID_DEV,
client_secret=CRONOFY_CLIENT_SECRET_DEV)
cronofy.user_auth_link("http://localhost:8080/")
We get the following error.
PyCronofyRequestError: Response: 406: None
Request: GET https://app.cronofy.com/oauth/authorize?state=&redirect_uri=https%3A%2F%2Fapp.example.com%2Fcronofy%2Fauthcallback&response_type=code&client_id=BLAHBLAH&scope=read_account+list_calendars+read_events+create_event+delete_event&avoid_linking=False
Request Headers:{'Content-Length': '2', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'User-Agent': 'PyCronofy 1.0.0', 'Connection': 'keep-alive', 'Content-Type': 'application/json'}
Response Content:
{
"error": "This URL should not be requested programmatically. You should send the user to this URL in a browser instead to request their authorization.",
"url": "https://app.cronofy.com/oauth/authorize?state=&redirect_uri=https%3A%2F%2Fapp.example.com%2Fcronofy%2Fauthcallback&response_type=code&client_id=BLAHBLAH&scope=read_account+list_calendars+read_events+create_event+delete_event&avoid_linking=False"
}
On debugging the client.py
i found that we were requesting the URL using GET instead of directly returning it here
https://github.com/venuebook/pycronofy/blob/master/pycronofy/client.py#L285-L296
response = self.request_handler.get(
url='%s/oauth/authorize' % settings.APP_BASE_URL,
params={
'response_type': 'code',
'client_id': self.auth.client_id,
'redirect_uri': redirect_uri,
'scope': scope,
'state': state,
'avoid_linking': avoid_linking,
}
)
return response.url
I suppose something has changed on Cronofy's end and it now returns an error instead.
Hence replacing the above with something like this seems to work fine.
import urllib
url = '%s/oauth/authorize' % settings.APP_BASE_URL
params = {
'response_type': 'code',
'client_id': self.auth.client_id,
'redirect_uri': redirect_uri,
'scope': scope,
'state': state,
'avoid_linking': avoid_linking,
}
urlencoded_params = urllib.urlencode(params)
return "{url}?{params}".format(url=url, params=urlencoded_params)
How can I check access token is expired or not, because every time cronofy.is_authorization_expired() return true.
Should I check for false response?
I means return true means -> token is expired
Or return false means -> token is expired
Which is correct and how can I assure that token is expired?
I just want to test sending emails including meetings created by Coronofy in my local, but I am stuck in the step call back URL with the following error: Callback URL must not be an example or local URL
this is URL raises the error: http://localhost:8000/clubs/cronofy/callback/
Hi,
The availability function should use API key, missing use_api_key=True
file: https://github.com/cronofy/pycronofy/blob/master/pycronofy/client.py
line: 496
return self.request_handler.post(endpoint='availability', use_api_key=True, data=options).json()[response_element]
Get this error after installing pycronofy with pip:
File "..../lib/python3.6/site-packages/pycronofy/__init__.py", line 1, in <module>
from pycronofy.client import Client # noqa: F401
File "..../lib/python3.6/site-packages/pycronofy/client.py", line 3, in <module>
from future.standard_library import hooks
ModuleNotFoundError: No module named 'future'
Several API calls do not use API_REGION_FORMAT setting, even when cronofy client is configured with data_center= 'de' option. Several methods in client.py use settings.API_BASE_URL directly instead.
Workaround: Change API_BASE_URL setting in settings.py. This works, if the default data center need not be used at all.
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.