All threads / How do I access google apis from a cron job?

Ask A Question

Notifications

You’re not receiving notifications from this thread.

How do I access google apis from a cron job?

Prasanna N asked in General

My requirement:
My cron job (a ruby script) would sync specific contacts between 2 google accounts.

Eg: Account A creates a contact in his (android) phone as "Lead John". It gets saved in google contacts automatically the next time he connects to wifi.
Account B, later creates another contact in his phone as "Lead Doe". It too gets saved.

The cron job's purpose is to fetch and sync all contacts starting with "Lead" between the 2 accounts.
So, after the next run of the cron job, both Account A and B will have "Lead John" and "Lead Doe" in their phones even though each created only one by themselves.

When I set about to write the code for this, in the google developer console, while trying to get credentials for the "project" that I was creating, google asked from where I'll be accessing these apis. I chose "cron job/daemon" and selected "User data".
But then I got this alert: "User data cannot be accessed from a platform without a UI because it requires user interaction for sign-in".

Account A and Account B are just my friends and assume that I can get any sort of api keys/secrets from their account with their consent.

So, my question is, without resorting to developing a webapp with oauth enabled, can I get this cron ruby script working?

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 33,399+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.