cronofy / cronofy-node

Node wrapper for the Cronofy API
https://docs.cronofy.com/developers
MIT License
49 stars 23 forks source link

Adding Multiple Calendars to a same sub #69

Closed rahul-wi closed 4 years ago

rahul-wi commented 4 years ago

When I try to use

https://app.cronofy.com/oauth/authorize ?response_type=code &client_id={CLIENT_ID} &redirect_uri={REDIRECT_URI} &scope={SCOPE} &state={STATE}

This returns us a code which is used to obtain an access token and after that a new 'sub' is created and now when I try to add multiple calendars then it gets added to the same sub which is perfectly fine as "app.cronofy.com" sessions gets maintained until then, now when I try to login in my application again with another user, then it keeps on adding the calendars in the same subId which is not desired, I do not wish to add it because these addition of calendars should be added to new 'sub'

Then after investigation found that there is another param 'avoid_linking' which when set true creates new 'sub' at every call, but this does not add calendar to a particular sub but creates a new sub everytime.

My requirement here is to create a 'sub' for each user of my application, I can store the account_id somewhere with me in my DB for that user, and now if the user tries to add a calendar then it should must be added to the same sub rather than creating a new one.

CharGomez commented 4 years ago

Hi @rahul-wi

were you able to solve this issue and achieve what was expected? I need to create the same functionality I mean one sub for each user...it seems like the dev account allows to handle just one user and all the calendar syncs are inserted under the same sub...not sure if its the dev account or is the normal behavior of Cronofy.

Thanks.

CharGomez commented 4 years ago

Hi @karlofy

I'm having the same issue as @rahul-wi, can you please help me with this so we're able to complete our investigation/testing and move forward with the implementation and prod build.

thanks

rahul-wi commented 4 years ago

Hi @CharGomez

So, here is what we did, We stored the subIds for a particular user with us, and for fetching the availability of the user, we fetched the calendarIds of the user from the subIds that were stored with us, and requested availabilities from cronofy and passed all the calendarIds that were synced by a particular user.

I hope this helps.