Coder Social home page Coder Social logo

pycronofy's People

Contributors

adambird avatar adamwhittingham avatar cbear99 avatar chrisburch avatar colbeanz avatar cronofymatt avatar danpoz avatar danpozmanter avatar fantasticole avatar grajo avatar gshutler avatar jkatz avatar jstacoder avatar madalosso avatar marcin-ro avatar matthewelwell avatar nevett avatar sandyrogers avatar stephenbinns avatar tz277 avatar ypcrumble avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

pycronofy's Issues

How to get only calendars added by particular user?

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

Revoking authorization uses the access token instead of the refresh token

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:

def revoke_authorization(self):

'token': self.auth.access_token,

This gives issues when the access token has expired.
Is there a specific reason the access token is used here?

Flaky test

pycronofy/tests/test_client.py::test_refresh can fail when running with pytest --randomly-seed=1234.

Cronofy date obj/dict for creating events not supported

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.

timezone_id not being set

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)

Suggestion: Implement MyPy type hints in the code

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.

Oauth autentication example not working

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

requests/pytz are not marked as dependencies

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]

user_auth_link() Returns a 406 PyCronofyRequestError

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)

Why cronofy.is_authorization_expired() always return true?

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?

how to fix `Callback URL must not be an example or local URL`

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/

future is a dependency

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'

data_center supplied to Client not used in all API calls

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.