- Timely Backend Engineer TestAs a user, I want to have my Google Calendar events for today listed on a Web interface, classified by calendar names.
- The events should import and save to db when I connect my account to Google calendar for the first time, the subsequent events which get created/updated/deleted should be sync'd to the db automatically.
- Using the latest versions of Ruby and Rails would be preferred with proper test cases and following Ruby coding style guides. We use RSpec for writing test cases but minitest is also fine.
- Using the Google Calendar APIs directly rather than using a gem would be preferred.
-
Install rvm
-
Install ruby 3.0.2
rvm install 3.0.2
- Install Postgres
sudo apt install postgresql-12 libpq-dev
https://www.youtube.com/watch?v=w6rzVKBsB3A
- In order to access google api in development enviornmant we need a secure url, for this purpose I've used Ngrok
https://ngrok.com/
- Goto config/settings/development.yml and update the host to ngrok secure url https://....
- Goto
https://console.cloud.google.com/apis/credentials
in theOAuth 2.0 Client IDs
section.- update the
Authorized JavaScript origins
with hengrok secure url
Example : https://fd95-2401-4900-1c33-c-61ac-49ec.in.ngrok.io
- Update the
Authorized redirect URIs
Example : https://fd95-2401-4900-1c33-c19c-84b1-77fb-6ngrok.io/auth/google_oauth2/callback
- update the
create and Open .env
- Update
DATABASE_URL
in.env
as per localpsql
creds. For example, if the user isaniket
and password isaniket
, change the variable as `DATABASE_URL="postgres://aniket:aniket@localhost/google_Calendar_api?encoding=utf8&pool=5&timeout=5000"
- In rails console
EDITOR=nano rails credentials:edit
update the google client_id and client_secret
google_calendar:
client_id:
client_secret:
- Goto
https://console.cloud.google.com/apis/credentials/consent
in theTest User
section. - and
add user
- While publishing status is set to "Testing", only test users are able to access the app.