Python Plugin: OAuth 2.0 to Access Google APIs

Python and python framework

Moderator: leecollings

Post Reply
BakSeeDaa
Posts: 485
Joined: Thursday 17 September 2015 10:13
Target OS: Raspberry Pi / ODroid
Domoticz version:

Python Plugin: OAuth 2.0 to Access Google APIs

Post by BakSeeDaa »

I intend to make a Python Plugin for accessing a Google Calendar (private and public) in Domoticz. Google APIs use the OAuth 2.0 protocol for authentication and authorization.

The idea is that You create a new hardware type GCal (That is a Python Plugin), enter Calendar ID, Client ID, and Client Secret (Obtained from the Google API Console.) and click save.

Then there is a authentication step where the user logs in with their Google account. After logging in, the user is asked whether they are willing to grant the permissions that Domoticz is requesting. This process is called user consent. I need a way to initiate this process after the configuration details has been filled in. If I could have a button to click to initiate the user consent (a redirect will occur)
I have no idea if it's feasible or not.

@Dnpwwo, what do You think?
User avatar
remb0
Posts: 499
Joined: Thursday 11 July 2013 22:21
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: Python Plugin: OAuth 2.0 to Access Google APIs

Post by remb0 »

moved to python.
ayasystems
Posts: 66
Joined: Tuesday 19 April 2016 23:37
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: OAuth 2.0 to Access Google APIs

Post by ayasystems »

I have your idea implemented.... domoticz speech my calendar when the pir raise the signal in the morning

Chech the google example all is writen

https://developers.google.com/google-ap ... art/python

Ask me your doubs

Sorry my english is not very good
User avatar
gizmocuz
Posts: 2551
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: Python Plugin: OAuth 2.0 to Access Google APIs

Post by gizmocuz »

I think there should be an option to also provide some javascript (logic) in the plugin setup
(Currently we have only parameters)
And a way to be able to call a function in the python script for configuration
I am facing a similar issue, i want to press a setup button that asks from my python script via an UDP broadcast what devices are there
Maybe one function with a parameter so we can use it many times

And if we can also have a <script></script> section in the setup, that would be great

Maybe add a 'Button' parameter with a function option, still when data is returned you need some logic

Or a default OAuth2 setup handler as this gets more common everyday (logitech harmony for example)
Quality outlives Quantity!
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Python Plugin: OAuth 2.0 to Access Google APIs

Post by Dnpwwo »

Couple of thoughts:
  • We could certainly add to the XML definition. Depends how generic we wanted it to be. A button tag with associated action script would be easy or we could add a generic HTML section and people could go crazy doing anything they want :o, I don't mind either way let me know what you prefer
  • An OAuth2 provider is a good idea but would be some way off. Currently the framework supports HTTP (almost), it doesn't even support HTTPS yet. There are a number of protocols that could be supported, I'm currently looking at HNAP1 which someone in Greece has exposed to me running on a DLink DSP-W215 switch which is a SOAP based protocol
  • The Hardware page calling back to plugin would be problematic, mainly because there is no guarantee that the plugin is running (the first time you configure it for example), would be easier to potentially send the plugin commands via Domoticz in the same way you can from Lua but via the web front end but with a response being returned. I guess understanding the use cases for this would help shape the solution.
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
BakSeeDaa
Posts: 485
Joined: Thursday 17 September 2015 10:13
Target OS: Raspberry Pi / ODroid
Domoticz version:

Re: Python Plugin: OAuth 2.0 to Access Google APIs

Post by BakSeeDaa »

gizmocuz wrote:...
Or a default OAuth2 setup handler as this gets more common everyday (logitech harmony for example)
Nice idea... Would that be independent of the Python Plugin? I believe it would open up many doors and the numbers of use cases are vast ...
User avatar
gizmocuz
Posts: 2551
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: Python Plugin: OAuth 2.0 to Access Google APIs

Post by gizmocuz »

The Hardware page calling back to plugin would be problematic, mainly because there is no guarantee that the plugin is running (the first time you configure it for example), would be easier to potentially send the plugin commands via Domoticz in the same way you can from Lua but via the web front end but with a response being returned. I guess understanding the use cases for this would help shape the solution.
If the plugin is found in the hardware page, it can be loaded.

If this function is 'static', not depending on the plugin, we might could use this ?
For example a button that will auto detect a UPNP device via a UDP broadcast and returns if found an IP address (or another object structure)
Quality outlives Quantity!
dynasticorpheus
Posts: 115
Joined: Monday 12 October 2015 15:26
Target OS: Linux
Domoticz version: 2.3295
Location: NL
Contact:

Re: Python Plugin: OAuth 2.0 to Access Google APIs

Post by dynasticorpheus »

BakSeeDaa wrote:
gizmocuz wrote:...
Or a default OAuth2 setup handler as this gets more common everyday (logitech harmony for example)
Nice idea... Would that be independent of the Python Plugin? I believe it would open up many doors and the numbers of use cases are vast ...
I second that
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest